Cross-compiling QT C++ for windows on linux
Uncategorized June 8th, 2010I've been trying to get cross-compiling to work on my linux box for quite some time now.
Now that it's finally working, I decided it was something that had to be shared π
Now that it's finally working, I decided it was something that had to be shared π
I wanted to cross-compile to build nightlies for a new, open-source and cross-platform p2p application π
To be clear, I'm not trying to write a full tutorial, just some basic guidelines to get you started.
To be clear, I'm not trying to write a full tutorial, just some basic guidelines to get you started.
Step 1: Set up a MinGW cross-compile environment
Normally this would take some time, but you can get a script that does it all for you from http://www.mingw.org/wiki/LinuxCrossMinGW.
$ sh x86-mingw32-build.sh
Follow the steps on your screen, this should be straight-forward.
For this guide, I assume you have installed MinGW in /home/user/mingw32/.
Step 2: Compile QT
We have two options here:
- Cross-compile QT on linux: don't. It'll take you too much time. There is a guide that covers this pretty well though on Divided Mind. It's for an older QT version, I didn't get it to work.
- Pre-compile QT on windows: this will take you far less time π This is what I'll try to cover a bit:
Install the SDK on your windows box (if you have QT Creator installed, you have the SDK already).
For me, QT was installed in C:\Qt\2010.02.1\qt. (Mind the qt subdirectory!) Now copy this whole directory and transfer it to your linux box.
I will assume you have put the contents in /home/user/qtwin/, which should contain an "include" and "lib" directory.
I will assume you have put the contents in /home/user/qtwin/, which should contain an "include" and "lib" directory.
Step 3: Modding QT on linux
You should have QT installed on your linux box as well. Amongst the lines I executed on my debian box were:
$ apt-get build-dep qt4-qmake
I also needed this one:
$ apt-get install libphonon-dev
Now find out where the QT "mkspecs" directory is located on your linux box.
$ find / -type d -name "mkspecs"
This should at least return the directory where APT installed QT, and the directory that you transfered to /home/user/qtwin.
The APT directory was /usr/share/qt4/mkspecs in my case. Changedir to it, now:
$ cp -r win32-g++ win32-x-g++
The win32-g++ directory (and now win32-x-g++ too) contain a file called qmake.conf. It tells QT which tools to use for compiling.
Standard, it uses windows tools (like "xcopy" and "del"). You have to replace the ones in win32-x-g++/qmake.conf with their linux counterpart.
You'll also have to modifiy include and library dirs, and make it use the MinGW tools.
You can find my own modded qmake.conf on pastebin (it isn't perfect, but will give you an idea).ΓΒ This is a very important step, so make sure to get it right π
You can find my own modded qmake.conf on pastebin (it isn't perfect, but will give you an idea).ΓΒ This is a very important step, so make sure to get it right π
Step 4: Compiling your application
Yes, we're here already π
Changedir to your project directory and execute:
$ qmake -spec win32-x-g++
So generally compile as you do usually but with another -spec flag.
$ make
And, see if it works!
Kudos:
Links that helped me a lot:
November 5th, 2011 at 2:22 am
Here (http://blog.kermat.net/blog5.php/cross-compilation-with-qt) you can find a complete tutorial to set up a cross-compilation environment with Qt. There is also a downloadable script that automates the installation. Tested with Qt 4.7.2.
November 27th, 2019 at 8:10 am
Do you want more people to visit your website? Get hundreds of people who are ready to buy sent directly to your website. Boost your profits quick. Start seeing results in as little as 48 hours. To get info send a reply to: [email protected]
March 18th, 2020 at 8:56 pm
Do you want to submit your ad on 1000's of Advertising sites every month? Pay one low monthly fee and get virtually endless traffic to your site forever!
Get more info by visiting: http://bit.ly/adpostingrobot
March 23rd, 2020 at 7:49 am
Looking to burn fat quick and without doing insane amounts of exercise or changing your diet? Take a look at this: http://bit.ly/fixbellyfateasy
January 2nd, 2021 at 7:10 am
Text To Speech In 3 Clicks - Real sounding human voices!. Don't take our word for it, hear a free demo now. Write a reply here: [email protected]
January 21st, 2021 at 1:42 pm
Have you heard that notes like these that come through your website's contact page are in effect an excellent way to generate leads for your online or offline business? How exactly do we do this? Easy, we craft an ad like the one you're reading right now for your online business and we blast it out to millions website contact forms on any website and in any business category or area you need. Does this work? Since you've ready my entire message then you're proof that they do! The best part is, this won't cost you much more than $3 a day! Interested in more details? send a reply here: [email protected]