Building 64-bit Qt 4.7 using MinGW-w64
(Nov 12, 2010)I successfully built 64-bit Qt libraries using MinGW-w64. Although I had to change Qt source code, it was only one line of code in the current source tree of qt-mingw-w64. The steps I took to built 64-bit Qt are described below. Note that my explanation is a bit verbose, as those who just start using MinGW or Qt may need additional information.
- Obtain Qt 4.7 source code.
- Go to http://gitorious.org/+qt-mingw-w64/qt/qt-mingw-w64-qt
- Click on the 'Source tree' button. Note that you can directly go to this link. However, go to the link above allows you to read recent activities of Qt development that may related to you.
- On the right side, you see several 'branches'. As of Nov 12, 2010, the one you want to use is plain '4.7,' which already merges Webkit facility.
- Once you click on the '4.7' button, you probably need to wait a minute or two. This allows the server to create tar.gz for downloading. Basically, the package is prepared on the fly. This is how gitorious works.
- Unpack the source tree to your preferred folder. For this note, I unpacked it to 'F:\Qt\qt-4.7.1_mingw_w64.' This path is used here for a demonstration purpose.
- Fix file 'src\corelib\tools\qsimd.cpp' by changing line 289 from 'long tmp' to 'quint64 tmp,' as suggested by Jonathan Liu [ref]. See the ref for more information if you don't understand what I meant. Please note that if you get a newer Qt version, this problem may already be solved.
- Get MinGW-w64 from sourceforge. I use the native compiler for Windows 64-bit. FYI: MinGW offers a cross-compilation feature. You can use Linux or 32-bit Windows to produce 64-bit Windows binary.
- Go to http://sourceforge.net/projects/mingw-w64/files/
- Click on Section 'Toolchains targetting Win64'
- Pick the release you like. I suggest you use personal build from sezero, as sezero usually adds some patches or features that you might want to use (e.g., updated OpenGL and OpenCL headers). I employed mingw-w64-bin_x86_64-ming_20101003_sezero.zip. By the time you get MinGW from sourceforge, the build may be gone. Yet, you are supposed to get a newer version than mine.
- If you wonder what are inside each sezero build see his note in Section 'Toolchains targetting Win64 -> Personal Builds -> sezero_20101003.' sezero did a good job in bookkeeping (at least it seemed).
- Personal build of rubenvb is probably an interesting choice, as he appears to be a Qt contributor. I believe that his MinGW build should not have a serious issue with Qt compilation.
- Unpack MinGW to a preferred place. For this note, it is 'D:\mingw_w64_sezero_oct_3_2010.'
- Go to D:\mingw_w64_sezero_oct_3_2010\bin and change gmake.exe to mingw32-make.exe. Note that it is MinGW's gmake not Qt's qmake. I backed up original mingw32-make.exe to other file first, although they might be exactly the same binary in the sezero's build.
- Download Perl. Yes, you need Perl to syncqt during compilation. I suggest ActivePerl Community Edition. If you want to repeat what I did here, download Windows 64-bit version with an MSI installer. I did not like Strawberry Perl, as I encountered many issues with it during past summer, especially the fact that it comes with its own GCC. Its GCC confused me about GCC version since both Strawberry's and MinGW's GCC showed up in the path. These issues may be already resolved by now, though.
- Install Perl. What a simple task if you have admin right to your machine. If you don't, see steps below.
- Download AS Package (ZIP).
- Unpack and set path to 'base_perl_path/bin' and 'base_perl_path/site/bin.'
- If you want a temporary session path for your command prompt (cmd.exe), type 'set PATH=C:\Perl64\bin;C:\Perl64\site\bin;%PATH%, provided that you unpack its main contents to C:\Perl64 and discard its 'support' folder. Don't close this command prompt yet because your path settings are temporary. You need to use it until the end.
- Now, you have all you need to embark the actual compilation phase. Set path to your MinGW folder. For example, 'set PATH=D:\mingw_w64_sezero_oct_3_2010\bin;%PATH%.'
If you want to know what your current path is, type 'echo %PATH%.' - Set QTDIR variable by typing 'set QTDIR=F:\Qt\qt-4.7.1_mingw_w64\bin.'
- Go to Qt base folder (F:\Qt\qt-4.7.1_mingw_w64) and run configure from the command prompt. You can choose any configure options, perhaps except phonon (my Qt build did not have phonon). I used 'plain' configure that generated everything, but you might want to get rid of many things, especially qt3 support, examples, and demos.
Update (Feb 18, 2011): it is easy to build Qt with phonon. The option, however, is off by default for MinGW. I tested with
configure -opensource -phonon -no-qt3support -nomake example -nomake demos
Although I did not test if the created libraries work or not, things are built smoothly. - Type 'gmake.' Note that if you want to try multi-threaded compilation, type 'gmake -jx,' where x is the number of threads. For instance, 'gmake -j2' for a dual-core machine, 'gmake -j4' for a quad-core machine, and 'gmake -j6' for a six-core machine (if you want to put every core to work). I, however, just used gmake with no option since I wanted to simplify everything for this build.
- Wait with patience.
The following summarizes downloads and tweaks I made during the above steps. Basically, we need to do only two things in addition to what most people do with mingw 32-bit. I have not try building phonon yet (and I think I don't need it for a long time).
Download summary
- Qt 4.7 mingw-w64 branch (~ 130 MB). See step 1.
- MinGW-w64 (~ 55 MB). See step 4.
- ActivePerl (~ 24 MB). See step 7.
Tweak summary
- Change source code (1 file, 1 line). See step 3.
- Change gmake to mingw32-make.exe. See step 6. (May not be necessary any more.)
Hope this helps,
Pinyo Taeprasartsit
Additional reference: mingw-w64 mail archive
I welcome questions and comments. Feel free to ask and share if you have any.
14 comments:
Thanks alot for this post.It really helped alot!
Anybody able to compile vlc (1.2.0 - from git repo) for win64 with qt 4.7 enabled using mingw-w64?
I have tried two times as in manual. I always missed the qtcreator.exe in the "Qt \ qt-4.7.1_mingw_w64 \ bin".
What am I doing wrong?
I did not quite understand point 11. "... I used 'plain' configure " . What does that mean? How should be the command line?
greetings
nanochen
@nanochen
I am not sure if we are talking about the same thing, as qtcreator.exe is another product from Nokia. It is not generated by building Qt libraries.
To be exact, Qt 4.7.1 is a set of libraries, while Qt Creator is an integrated development environment (IDE).
If you download and install Qt Creator 2.0.1, you will get qtcreator.exe, but usually in its own directory, not in Qt\qt-4.7.1_mingw_w64\bin.
Regarding the 'plain' configure, it is just 'configure' without any explicit option.
Hope this helps,
Pinyo
@pinyotae
oh, sorry I'm still learning. Please help me. I thought I would get a complete development environment for 64bit. At least the build process has created also designer.exe and assistant.exe in the "qt-4.7.1_mingw_w64 \ bin" path.
I probably have understood the topic "Building 64-bit 4.7 Qt using MinGW-w64" completely false. Why do we need it, then?
Greetings
nanochen
Hello again nanochen,
The Qt library can be used in many well-known IDEs. Building it individually allows you to choose an IDE you prefer (e.g., Eclipse, Qt Creator).
In addition, Qt Creator can be employed with many compilers, not restricted to GCC, not to 32-bit or 64-bit (both 32- and 64-bit are fine). Therefore, making two separate products is an reasonable choice.
For me, I mainly use Visual Studio and Eclipse-GCC. So, I compiled Qt libraries for both Visual Studio and Eclipse since libraries for Visual Studio and Eclipse-GCC are not compatible. But, the compiled libraries from GCC can be used in both Eclipse and Qt Creator, as long as you configure the IDEs to work with GCC.
FYI: Eclipse and Qt Creator are similar in that they are compatible with more than one compiler, but GCC is the most common one.
Oh, very well. Maybe I understand it.
Ok, if I (as Visuall Studio) another development environment, and with just that I want to use Qt program, I use in this case, "Building 64-bit 7.4 Qt using MinGW-w64".
But why then are the addins under http://qt.nokia.com/downloads "under" Other Downloads "?
Greetings
Arne
@nanochen
Visual Studio add-in (and Eclipse integration) allows you to conveniently work with your Qt projects.
For example, you can create a Qt project with supporting files that are automatically generated by the add-in. Without the add-in, you have to manually create these supporting files, configure the compiler to instantiate Qt macros, and specify additional compiling steps. These tasks are laborious, error-prone, and relatively difficult to learn. Therefore, using the add-in is highly recommended, as it does these jobs for you.
Moreover, the add-in allows you to quickly switch Qt versions. For instance, if you have both Qt 4.4 and 4.7 installed, you can quickly switch Qt versions back and forth to test compatibility.
Finally, the add-in binds Visual Studio with Qt Designer. Thus, you can visually design the GUI in a similar way that people do in Visual Basic or MFC GUI creation. This is a must-have feature for most people.
I suggest you use the add-in, if you can use it in your development environment.
Hope this helps,
Pinyo
@Maks Brrr
My Blogger strangely behaves for a past few months. Several comments did not show up, even though I did not filter any thing out. I, however, received comment notifications from Blogger.
For your question, I gladly allow you to translate to Russian and make a link back here.
(This message refers to
Maks Brrr. has left a new comment on your post "Building 64-bit Qt 4.7 using MinGW-w64":
Thanks a lot for your investigation. There is a too few of information about development using Open Source tools on Windows x64 environment on the Internet. This instruction and the article how to use Eclipse with MinGW-64 is very helpful for me.
I'm native Russian speaker. So may I translate this article into russian and publish it on most popular russian IT
collaborative blog (http://habrahabr.ru), of course with the link to your original post?
Thanks.)
I know your post is almost a year old, but it seems to be the closest thing I can find. Has qt_mingw_w64 been merged back into the main qt trunk? The link is dead and the project looks empty. Thanks!
@Jonathan
For the latest time I built MinGW, I believe I did not need to manually patch it anymore.
So, I think you can just grab the latest stable version and build it normally.
hi can you please let me know what version of Eclipse is compatible with QT version 4.7- deven
@dev your question is quite difficult, according to the current situation. I think you expect 'Eclipse integration' which is available from http://qt.nokia.com/products/eclipse-integration/ .
Unfortunately, it was built with Qt 4.6, which is not 64-bit MinGW compatible. So you have use the Eclipse-integration package with newer Qt lib. Although it worked correctly when use it. There might be something broken or some features may not be available.
For the answer of your question, I can say that Eclipse Indigo and Helios work with Qt fine. You, however, might need to aware of possible failures from integration.
Thanks for this. Using it as a rough guide I was able to build a working version of QT 4.8 just now :)
Post a Comment