[Solved] Compiling 64bit Qt 4.7.3 using MinGW



  • Hello all! I'm a newbie when it comes to compiling or building libraries, so I'm probably getting some of the nomenclature wrong. I've done many google and forum searches on building 64bit Qt with and without mingw, so hopefully I didn't miss this being answered elsewhere. Sorry for the long post... just trying to be thorough.

    Ultimate goal: I'm attempting to build a 64bit version of Qt 4.7.3 on Windows7x64 that can support MinGW as its compiler under Qt Creator 2.2.1. I'm doing this within Visual Studio 2010's 64bit command prompt (no service packs).

    Mild success: I have been able to somewhat successfully build a 64bit version of Qt by generally following the instructions "here":http://doc.qt.nokia.com/4.7/install-win.html, with a slight modification in that it was explicitly built for the win32-msvc2010 platform. This works fairly well using Visual Studio's compiler in Qt Creator, but I'd like to divorce the final build from Visual Studio by assigning MinGW-64 as my compiler.

    Failure: So, I wanted to try building Qt 4.7.3 for the win32-g++ platform. I set my environment variables like so:
    PATH=C:\dev\Qt\4.7.3_x64_g++\bin;C:\mingw64\bin
    QMAKESPEC=win32-g++
    QTDIR=C:\dev\Qt\4.7.3_x64_g++

    I downloaded the Qt 4.7.3 source code zip file from nokia (http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.3.zip) and rubenvb's latest gcc 4.6.2 64bit MinGW version (http://mingw-w64.sourceforge.net/). I extracted them to their respective directories at C:\dev\Qt\4.7.3_x64_g++\ and C:\dev\mingw64.

    The standard windows cmd shell kept giving me errors during the build, so I unzipped a clean copy of 4.7.3-src and launched the "Visual Studio x64 Win64 Command Prompt (2010)" from the start menu. I navigated to C:\dev\Qt\4.7.3_x64_g++\ and entered the following commands...

    @configure.exe -opensource -debug-and-release -platform win32-g++@
    and it hit a syntax error with the following output:

    @copy qmake.exe C:\dev\Qt\4.7.3_x64_g++\bin\qmake.exe
    The syntax of the command is incorrect.
    mingw32-make: [qmake.exe] Error 1 (ignored)
    Creating makefiles in src...
    Generating Makefiles...
    execute: File or path is not found (C:/dev/Qt/4.7.3_x64_g++/bin/qmake)
    Qmake failed, return code -1@
    Since qmake.exe existed in C:\dev\Qt\4.7.3_x64_g++\qmake\ I figured that I could safely manually copy it over to the QTDIR bin folder. After that, I re-ran configure and it picked up where it left off, outputting a series of "Reading _____" lines going back and forth between C:/ and C:\ directory styles with warnings about unescaped backslashes.

    It the initial build seemed to succeed, telling me to run mingw32-make, so I did. MinGW then flooded the command prompt with error messages similar to the following:
    @c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE/string.h:172:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
    c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE/new:84:55: error: declaration of 'operator new' as non-function
    c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE/new:84:55: error: 'size_t' was not declared in this scope@

    Note the mid-command switch between slash styles around "INCLUDE" in the output (???). mingw32-make eventually quit after a few seconds of this kind of nonsense with the following lines:

    @c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE/new:87:57: error: 'size_t' was not declared in this scope
    c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE/new:87:71: error: expected primary-expression before 'const'
    mingw32-make[2]: *** [tmp/obj/release_shared/qisciicodec.o] Error 1
    mingw32-make[2]: Leaving directory 'c:/dev/Qt/4.7.3_x64_g++/src/tools/bootstrap'
    mingw32-make[1]: *** [release] Error 2
    mingw32-make[1]: Leaving directory 'c:/dev/Qt/4.7.3_x64_g++/src/tools/bootstrap'
    mingw32-make: *** [sub-tools-bootstrap-make_default-ordered] Error 2@

    Any ideas on what the issue might be? Would patching Visual Studio with Service Pack 1 help this? "This thread":http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/ vaguely suggests that there are some issues compiling 64bit Qt with vanilla VS 2010. Any input would be appreciated.


  • Moderators

    Hi phlucious

    you have provided quite a long list of details, which is certainly good. However, it is also quite complex to understand. So I might raise questions you have already answered.

    From my point of view you should separate completely the different compilation trials. Some of your problems seem to be the reason of a mix of mingw and msvc. Therefore, if you like to have both options open, you should concentrate on one at a time.

    [quote author="phlucious" date="1314405842"]
    Any ideas on what the issue might be? Would patching Visual Studio with Service Pack 1 help this? "This thread":http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/ vaguely suggests that there are some issues compiling 64bit Qt with vanilla VS 2010. Any input would be appreciated.[/quote]

    My personal opinion is to use all service packs for visual studio. At least with msvc2005 I made reasonably good experience.

    [quote author="phlucious" date="1314405842"]
    The standard windows cmd shell kept giving me errors during the build, so I unzipped a clean copy of 4.7.3-src and launched the "Visual Studio x64 Win64 Command Prompt (2010)" from the start menu. I navigated to C:\dev\Qt\4.7.3_x64_g++\ and entered the following commands...
    [/quote]

    Why are you starting the vs Command prompt, when you want to compile a mingw version?
    There you will get the additional msvc specific environment into your compilation. But you want to use mingw only.



  • The C++ libraries of Visual Studio and MinGW are not compatible, you must not mix them. And to avoid getting the wrong includes into the path, you should not use the Visual Studio command prompt. The best would be to open the MinGW command prompt. I don't know the exact path (I have no windows box at the hand right now), that has the right paths set in the environment.



  • [quote author="koahnig" date="1314440011"]Hi phlucious
    you have provided quite a long list of details, which is certainly good. However, it is also quite complex to understand. So I might raise questions you have already answered. [/quote]

    No worries here. I'm just trying to be thorough, and I often find that the most obvious answer is the correct one.

    [quote author="koahnig" date="1314440011"]My personal opinion is to use all service packs for visual studio. At least with msvc2005 I made reasonably good experience.[/quote]
    I would if I could... I don't control the Visual Studio installation on my platform yet.

    [quote author="koahnig" date="1314440011"]Why are you starting the vs Command prompt, when you want to compile a mingw version? There you will get the additional msvc specific environment into your compilation. But you want to use mingw only.[/quote]
    [quote author="Volker" date="1314488306"]The C++ libraries of Visual Studio and MinGW are not compatible, you must not mix them. And to avoid getting the wrong includes into the path, you should not use the Visual Studio command prompt. The best would be to open the MinGW command prompt. I don't know the exact path (I have no windows box at the hand right now), that has the right paths set in the environment.[/quote]
    I had no idea that there was such a thing as a MinGW command prompt. I have had limited formal computer science training, so I don't yet fully understand the concept of a shell, or the differences between the command prompts (vanilla windows 7x64, visual studio x64, and mingw, for example), so I was shooting in the dark in terms of which command prompt to use. I'm open to reading a good source if you know of one. Does the standard windows CMD.exe lack certain environment variables that I would need to compile Qt using mingw?

    It might also be worth noting that I haven't yet installed the Qt SDK on my current machine since they just finished setting it up this morning. Would installing the SDK add some env variables and/or registry values that would help with the process?

    Thanks to you both for your helpful replies.



  • I think an important and more fundamental question is this: In order to compile programs with Qt Creator, do I also have a version of Qt compiled using the same compiler?


  • Moderators

    [quote author="phlucious" date="1314641815"]
    I would if I could... I don't control the Visual Studio installation on my platform yet.
    [/quote]
    Maybe you should talk to your computer administrator to update the service packs for vs.

    [quote author="phlucious" date="1314641815"]
    I had no idea that there was such a thing as a MinGW command prompt. I have had limited formal computer science training, so I don't yet fully understand the concept of a shell, or the differences between the command prompts (vanilla windows 7x64, visual studio x64, and mingw, for example), so I was shooting in the dark in terms of which command prompt to use. I'm open to reading a good source if you know of one. Does the standard windows CMD.exe lack certain environment variables that I would need to compile Qt using mingw?

    It might also be worth noting that I haven't yet installed the Qt SDK on my current machine since they just finished setting it up this morning. Would installing the SDK add some env variables and/or registry values that would help with the process?

    Thanks to you both for your helpful replies.[/quote]
    There is no special mingw command prompt. You would use the standard command prompt of your windows system. cmd is good enough for mingw. When using the msvc command prompt you have the environment set for visual studio. Otherwise nmake and the acess to the compiler is missing. And you must not mix the output of the different compilers.

    If you like to compile Qt you do not necessarily require the whole SDK. However, all depends on what you are really trying to achieve. In general I recommend to focus on one platform. There is no need to have Qt for msvc and mingw at the same time during development. Therefore, as long as you have no very good reason to do otherwise stay with either platform until you are familar with it.

    If you want to use msvc and have a licensed version of it you should use also vsaddin. This makes live a little easier.


  • Moderators

    [quote author="phlucious" date="1314642645"]I think an important and more fundamental question is this: In order to compile programs with Qt Creator, do I also have a version of Qt compiled using the same compiler?[/quote]

    You can use Qt creator also with the visual studio compilers as a tool chain. However, you might be on your own to fiddle out a number of details. In my opinion certainly nothing for starters.

    It is probably easiest to use Qt creator as it comes with the whole sdk on windows.



  • [quote author="koahnig" date="1314643786"]You would use the standard command prompt of your windows system. cmd is good enough for mingw. When using the msvc command prompt you have the environment set for visual studio. Otherwise nmake and the acess to the compiler is missing. And you must not mix the output of the different compilers. [/quote]

    Thanks for the clarification. What do you mean about mixing the output of different compilers? Using components of Qt (Qt Creator, Qt library, Qt Examples, etc) compiled using different compilers?

    [quote author="koahnig" date="1314643786"]If you like to compile Qt you do not necessarily require the whole SDK. However, all depends on what you are really trying to achieve. In general I recommend to focus on one platform. There is no need to have Qt for msvc and mingw at the same time during development. Therefore, as long as you have no very good reason to do otherwise stay with either platform until you are familar with it.[/quote]

    I'm trying to achieve two things: First and foremost, I need to be able to develop 64bit programs for the speed and memory improvements that come with it. I'll be pounding through LiDAR data, which often means massive files. Anything I can do to go faster means hours saved. Since I prefer C++ with Qt, this means that I have to compile my own 64bit version of 4.7.3. I'm new to compiling libraries, though, so the learning curve is pretty steep.

    Secondly, I've gotten used to Qt Creator and haven't used Visual Studio much for a year or two, so I'd prefer to develop there if I can do so in 64bit instead of downloading the VS add-in, especially since my admin has been slow about getting the service pack installed. Now seems as good a time as any to learn how to compile my own version(s) of Qt. I like having options.


  • Moderators

    [quote author="phlucious" date="1314644730"]
    Thanks for the clarification. What do you mean about mixing the output of different compilers? Using components of Qt (Qt Creator, Qt library, Qt Examples, etc) compiled using different compilers?
    [/quote]
    Since you can use Qt creator as the IDE with the ms compiler this is not considered to be a mix.
    A mix would be if you create a brand-new application with msvc and like to link with mingw libs. That is a nogo. If Qt is compliled with mingw, you can use it only for own applications compiled with mingw. The same hold true for msvc.

    Since you are familiar with Qt creator, it is probably the best choice to stay with it. If there are no restrictions to be compatible with other shared libs, you can use mingw. You might want check if the sdk is already readily available for 64 bit for windows. This would allow you to save the compilation of Qt.

    Yes, LiDAR data is often more than just a couple of kB ;-)



  • Hi There,

    Not a computerscientist? No problem...

    1st: gcc and vc++ compiler work differently. This means, as the other guys said, that if you start to work with a given compiler, you have to keep working only with it (or you will have problems), easier and simpler.

    2nd: Since you don't have too much background on computer science, keep it simple.

    3rd: since you are a programmer, you will have to install several stuff to test, discover and see what fits best to you. I recommend that you speak with your boss about some changes on the policy, so that you can have a bit more freedom to work.

    4th: Installation mingw64 is tricky, take a look at "these":http://sourceforge.net/apps/trac/mingw-w64/wiki/BuildingQt . You will need activePerl. Also use the latest win64 build (look at the txt on the download section of the page you have pointed:

    Sorry, the link is getting corupted, so i am writting it for you to copy and paste:
    http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/PersonalBuilds/sezero_20110510/
    Chose the right one for your OS version.

    5th: maybe you could really request (edit: politely) to the admin to install Qt 64 bits for you, this is a bad thing, but if he is the only one with the power to do it, empower him. You are no magician :-)

    Good Luck,
    VitorAMJ



  • Thanks to everyone for the helpful replies! I think I'm starting to understand the distinctions between IDE, library, compiler, and debugger.

    I was unable to find a stable enough 64bit version of MinGW to suit my needs, so I purchased a copy of Visual Studio 2010 (with SP1) and compiled my own 64bit version of the Qt library (4.7.4) for use in the 32bit Qt Creator (2.3.1, standalone version). For those wondering, I found the instructions at the following link VERY helpful!
    http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/

    The instructions "here":http://doc.qt.nokia.com/qtcreator-snapshot/creator-debugger-engines.html were very helpful for setting up 64bit debugging of my 64bit msvc2010 build of Qt in Qt Creator using the Windows SDK.

    Thanks again for your help! Hopefully soon Nokia/Trolltech will begin distributing 64bit versions of their libraries. I'm guessing that they're waiting for a stable version of 64bit MinGW that works with Qt.

    Cheers,
    Evon



  • I'm confused about the definition of 64bit version binaries.

    I have followed the http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/
    and seemingly successfully compiled Qt in my 64bit Windows 7 machine , but apparently it did not use "the x64 compiler" (as described http://doc.qt.nokia.com/4.7/install-win.html ) because I get
    @QtCored4.lib(QtCored4.dll) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
    1>@ when I try to use Qt in a x64 project

    and the demo executables don't run.
    [where as with http://get.qt.nokia.com/qt/source/qt-win-opensource-4.8.0-vs2010.exe the same linker error occurs, but the executables run]

    Please give your input on what seems to be happening



  • Sounds like you have 32bit and 64bit libraries mixed. Either you didn't compile Qt in 64bit, or your other libraries or project settings in Visual Studio are still 32bit.

    Make sure that you use the "Visual Studio x64 Win64 Command Prompt (2010)" when you attempt to compile Qt. I bring that up directly from my start menu. That's the only environment in which I've successfully compiled in 64bit. I use:

    configure.exe -debug-and-release -opensource -platform win32-msvc2010 -no-qt3support
    ..\jom106\jom.exe -j 4
    ..\jom106\jom.exe clean

    I gave up trying to install MinGW x64 and used MSVC2010 in Qt Creator like koahnig suggested. I don't use Visual Studio itself much as my IDE any more, so I can't help you there. You should probably start a new thread since this thread is about using MinGW.



  • Oh! I had missed the detail
    [quote]Make sure that you use the “Visual Studio x64 Win64 Command Prompt (2010)” when you attempt to compile Qt. I bring that up directly from my start menu.[/quote]I didn't first realize that there were different command prompts in MSVS
    Thanks!

    NOW I seem to have correctly compiled Qt in x64 (no linker error), but the demo executables weren't created..
    I wonder why, got a clue? :)



  • Glad to hear it's working. I've no idea why the demos won't compile... I just open qtdemo.exe in the bin folder of my new compile on the rare occasion that I use their demos. Most of the time I run into them on the online help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.