| Dear list readers, beginners, i have made a small tutorial on how to get MinGW MSYS / MinGW-w64 up and running, as well as how to compile Qt 4.8.1 as dynamic and static, how to configure Qt Creator to use the MinGW-w64 toolchain and how to compile Qt IFW with MinGW-w64. - First of all, and as i don't know who owns what here, i would like to make sure i can have credit to give links to downloads on the server (i don't give the direct download link, but the download page each time). - Second, i would like to get permission from Ruben, because i talk about "Ruben's build" in the tutorial. - Last, if any kind soul would help me correcting that horrible english of mine... That would be great. The tutorial is for now as a text file, so it's easily editable by anyone who wants to contribute to it (And i don't claim any rights on it). Then if you want this to be on the Wiki, i'm cool with it, as it would encourage people who can't afford MSVC to have a nice and tidy high-tech environnement for Qt :) Best, and good night. Pierre. |
1) Pre-requisites. a) Qt 4.8.1. Head to http://qt.nokia.com/downloads and get the latest installer. I am using the 4.8.1 version, full installer. You might want to only get the web installer tool, if you're planning to do this setup only once. Else, go for the full installer, as you'll only have to download the data one time.
b) Perl. To shadow-build Qt (To be able to have multiple clean build directories without manually copying the whole source tree each time), you might want to install a Perl version. I use the 5.14.2 version of ActivePerl that you might get here: http://www.activestate.com/activeperl/downloads Once installed, make sure Perl's bin is in your Windows PATH (You will compile Qt using the Windows command emulation environment). c) MinGW MSYS. As MinGW-w64 is a toolchain (A set of compiler, linker etc), you might like to get good old' POSIX tools. Some like Cygwin, i adopted MSYS for my needs. Once installed and configured, you will be able to invoke make, grep, ls, sed and any other binary you're used to under a Linux or Unix system. Go to http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/ and download the latest version (i use mingw-get-inst-20120426 right now). d) MinGW-w64. The next step is to get a build of MinGW-w64. While any build will do (You can pick one here: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/ ), i have been strongly advised to use a tested user-build. Right now, i'm using Ruben's build, which is ready-to-use, and well maintained. Also, people from the MinGW-w64 list are very kind people when you're asking the right questions. The one i'm using is Ruben's build i686-w64-mingw32-gcc-4.5.3-release-win32_rubenvb, but feel free to pick one close to your needs in terms of GCC version. 2) Unpacking everything in the right place. a) Installing MinGW MSYS. First, start by installing MinGW-GetInst. i only choose the MSYS system from the list, and i don't install any other piece of software (And you don't really need to, as you will be manually installing MinGW-w64). Once done, you will end having C:/MinGW offering you a nice POSIX toolset. b) Putting your toolchain at the right place. Then, you will have to unpack your MinGW-w64 build. Do it at the root of your hard disk in a folder named MinGW32 (As i'm using Windows XP 32 bits), and make sure that once unpacked you have the following filesystem tree: c:\MinGW32\bin\mingw32-make.exe c) Configure MSYS to play nice with MinGW-w64. Fire-up your favorite text editor (But avoid notepad, as it only show windows line breaks... You can easily get lost in shell scripts.), and go to c:\MinGW\msys\1.0\etc and open the file named fstab. Inside, make sure the /mingw mount is pointing to c:/MinGW32. You can also add other mounts in it, mine looks like this: c:/MinGW32 /mingw c:/QtSDK /QtSDK c:/Home/Administrator/Projects /Projects The /mingw mount only is important, because that's how your PATH is being built. Note that from now on, i'll be refering at these locations by their POSIX paths (e.g. /QtSDK). d) Testing if everything is good so far... Fire-up a MSYS shell (Usually by launching c:\MinGW\msys\1.0\msys.bat) and type (Without the quotes): "which gcc" then return. If you get something like "/mingw/bin/gcc.exe", then you're doing good. Else, you'll have to make sure that your MinGW-w64 toolchain is at the right place, and that your MSYS fstab is correctly showing the /mingw entry. d) Adding MinGW bin folder to your MSYS path. If you would like to enjoy the MSYS command-line installer, you might consider adding /c/MinGW/bin to your MSYS path. Do do that, you can open the file in /c/MinGW/msys/1.0/etc/profile and change the following 5 lines: if [ $MSYSTEM == MINGW32 ]; then export PATH=".:/usr/local/bin:/mingw/bin:/bin:$PATH" else export PATH=".:/usr/local/bin:/bin:/mingw/bin:$PATH" fi to: if [ $MSYSTEM == MINGW32 ]; then export PATH=".:/usr/local/bin:/mingw/bin:/bin:/c/MinGW/bin:$PATH" else export PATH=".:/usr/local/bin:/bin:/mingw/bin:/c/MinGW/bin:$PATH" fi Once done, re-source the file or restart the MSYS shell and you should have access to mingw-get. It's pretty handy, and i love to install extra packages, for instance with "mingw-get install msys-openssh". 3) Installing the Qt SDK / Building Qt. a) Installing the right packages. It's time to start the Qt SDK installer. I usually only install the following items, as i build the rest myself: - Development Tools: Qt Designer, Qt Assistant (To display help contents), Qt Linguist (Neat for translating your apps). - Miscellaneous: Qt 4.8.1 Sources (This one is important). b) Creating the Qt Build tree. In /QtSDK, build the following tree: "Desktop/Qt/4.8.1". Then, navigate to "/QtSDK/Desktop/Qt/4.8.1" and create a new folder named "i686-w64-mingw32" (To host the dynamic build) and another named "i686-w64-mingw32_static" (Well... It's pretty much self-explainatory). The names of these directories should match the target machine you're planning to build Qt for! c) Building the dynamic version of Qt. Navigate to C:\QtSDK\Desktop\Qt\4.8.1\i686-w64-mingw32 (Again, be carefull, i'll be refering to such path as /QtSDK/Desktop/4.8.1/-w64-mingw32 from now on, last warning) and create a file named "myConfigure.bat". Edit it with notepad this time, and write: set PATH=c:/MinGW32/bin;%PATH% ..\..\..\..\QtSources\4.8.1\configure.exe ^ -platform win32-g++ ^ -fast ^ -debug-and-release ^ -no-webkit ^ -no-phonon ^ -no-dbus ^ -no-opengl ^ -no-qt3support ^ -no-xmlpatterns ^ -no-multimedia ^ -no-declarative ^ -no-declarative-debug ^ -nomake examples ^ -nomake demos ^ -opensource You can tweak the options as you like, but make sure you at least keep the "-nomake" as it will highly speed up the build. Once done, fire up windows batch (*not* MSYS) and type: > cd C:\QtSDK\Desktop\Qt\4.8.1\i686-w64-mingw32 > myConfigure.bat Qt should be shadowing it's source tree, configure itself, and build QMake. Once done, you can then build it by typing "mingw32-make". The build process can be pretty long, depending on what CPU power you have. Be patient. d) Building the static version of Qt. If like me you're building Qt-based installers, you will like to have a static version of Qt to avoid redistributing a whole lot of libraries along with these installers. In this case, just follow the c) step, but change the folder to "i686-w64-mingw32_static" and in the configure batch put the following instead: set PATH=c:/MinGW32/bin;%PATH% ..\..\..\..\QtSources\4.8.1\configure.exe ^ -platform win32-g++ ^ -fast ^ -static ^ -release ^ -no-webkit ^ -no-phonon ^ -no-dbus ^ -no-opengl ^ -no-qt3support ^ -no-xmlpatterns ^ -no-multimedia ^ -no-declarative ^ -no-declarative-debug ^ -qt-sql-sqlite ^ -plugin-sql-sqlite ^ -nomake examples ^ -nomake demos ^ -opensource 4) Configuring Qt Creator. a) Adding your Toolchain. - Once you have started Qt Creator, go to the "Tools -> Options" menu. - Under the "Build & Run" topic select the "Toolchains" tab. - Click "Add -> MinGW", and select the new entry. - In the "Compiler Path" field, choose "C:\MinGW32\bin\mingw32-make.exe". - Then configure the ABI to the target machine you'll be building your projects. - Make sure the "Debugger Path" is set to "C:\QtSDK\pythongdb\python_2.7based\gdb-i686-pc-mingw32.exe". b) Adding your Qt Versions. - Still in the "Tools -> Options" menu, under the "Build & Run" topic, now select "Qt Versions". - Click "Add", and browse to "C:\QtSDK\Desktop\Qt\4.8.1\i686-w64-mingw32\bin\qmake.exe". - Repeat the "Add" step and browse to "C:\QtSDK\Desktop\Qt\4.8.1\i686-w64-mingw32_static\bin". You will then be able to choose between one or another when building your projects. If you get any error message about Qt Creator not being able to generate binaries for this version of Qt, make sure your Toolchain is configured correctly, and re-do step a) if necessary. 5) Preparing your copy of Qt IFW. a) Checking-out the source. - From MSYS bash, type: "mingw-get install libiconv msys-perl" - Install Git for Windows (You can get it here: http://code.google.com/p/msysgit/downloads/list I use Git-1.7.10-preview20120409), and make sure the "Associate .sh files to run with Bash" is unchecked. - Once installed, make sure "C:\Program Files\Git\bin" is in your MSYS PATH at the *lowest* priority, e.g. adding it like this: PATH=".:/usr/local/bin:/mingw/bin:/bin:/c/MinGW/bin:$PATH:/c/Program Files/Git/bin" - Restart your MSYS shell, and type git. You should get the help. b) Checkout Qt IFW source tree. - Fire up your MSYS shell and go to "/QtSDK/Desktop". - Type "git clone git://gitorious.org/qt-labs/installer-framework.git QtIFW". - Get the Qt IFW MinGW-w64 patch from here: https://bugreports.qt-project.org/secure/attachment/28210/MinGW-w64.diff and apply it to the source tree. - Now, Qt IFW should build (But make sure you're using the static version of Qt you've built, else, what's the point). - If required, add "C:\QtSDK\Desktop\QtIFW\bin" to your PATH so you can invoke binarycreator / repogen directly.
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
