Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[guide] how-to build Qt for Visual Studio 2010



  • After a lot of reading and trial and error, I could finally build Qt for VS2010, which works perfectly.

    I wrote a quick guide about it here (with link to Qt DevNet Forums in the references):
    http://stackoverflow.com/questions/5601950/how-to-build-qt-for-visual-studio-2010

    Feel free to correct me on parts where you feel I'm wrong (especially on the configure flags).



  • Hi zsero,

    could you also make a "wiki page for our wiki":http://developer.qt.nokia.com/wiki for that?



  • Hi,

    I am currently working on a serious qt project which was successfully built and developed previously in Linux with Qt4.5.x version on windows vista 64 bit machine using visual studio 2008.

    And now I would like to continue my development on windows 7 home premium, 64 bit machine(Dell INSPRON laptop) with visual studio 2010(RTM) installed.

    So I have recently downloaded qt-win-opensource-4.8.4-vs2010.exe from qt website and followed the instructions in this *"LINK":http://doc.qt.digia.com/4.7/install-win.html * .

    Then i did a cmake(version: 2.8) to my project source code and it was successfully generated a new build for VS2010 WIn64. so i have opened and tried building my visual studio 2010 project solution file from my new build but it is giving me a

    fatal error:LNK1112: module machine type 'X86' conflicts with target machine type 'x64', QtOpenGLd4.lib(QtOpenGLd4.dll).

    Also

    I have checked my VS2010-properties dialogue, Platform dropdown to "Active(x64)".

    In the "Configuration Manager..." in the top right, selected the platform to x64.

    went to Project Properties->Configuration Properties->Linker->Advanced->set the "Target Machine Platform" to MachineX64

    (/MACHINE:X64).

    So just for testing qt.8.4 on VS2010,

    • i have just created one simple project using qt4 VS plugin like File->qt projects-> and started debugging it.it was working fine for 32bit platform and giving the output a sample GUI window.
    • Again, just to test for 64bit platform,This time i have tried my setting my target platform to 64 bit by Right clicking on the project->Qt project settings->version(4.8.4) in properies->ok.
    • Also went to Project Properties->Configuration Properties->Linker->Advanced->set the "Target Machine Platform" to MachineX64 (/MACHINE:X64).
    • Then i debug the program, but it is not tagetting to 64bit platform and giving me the error saying that i have to set the qt version again.i went to qt settings again and checked it, there is no version number there?

    just for testing my VS2010,

    • I have created a simple hello world project and targeted to 64bit platform and debegged it. It is absolutely working fine.
    • And i am able to debug and test all my sample Opengl programs targeting to 64bit.

    Moreover i have updated my VS2010 ultimate to sevice pack 1, still the same fatal error:LNK1112: module machine type 'X86' conflicts with target machine type 'x64', QtOpenGLd4.lib(QtOpenGLd4.dll).

    Finally I have come accross this link: http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/. but seems to be complicated for me to do as these istructions are using perl :

    I couldn't able to figure it out , is this the problem with qt version i am using or the Visual studio version?or some compatibility issues with OpenGL? Can somebody please share your thoughts on this and help me?

    Also please let me know is there a best way that i can build and develop my previous cmake buld projects developed with qt4.5.x using newer qt versions in windows7 64bit with supported Visual Studio versions?

    Thanks in advance
    Regards
    Kumar


  • Lifetime Qt Champion

    Hi,

    The package you downloaded is built for 32bit. To have a 64bit Qt version, you have to download the source package (zip file) and build it yourself.

    Once downloaded and uncompressed (I would recommend c:\Qt\4.8.4):

    • start a 64bit command line (IIRC You can find it in the start menu/visual studio/tools)
    • cd to the directory where you uncompressed Qt's sources
    • run configure
    • nmake (if you have QtCreator installed you can also run jom which will parallelize the build)

    You should be all good

    Hope it helps



  • Thanks SGaint,

    I have download the source package (zip file) and followed your steps in your previous post. Now, It is perfectly configured to visual studio 2010 on my windows 7 64 bit laptop.I am able to build and run qt example projects.

    But when i try to debug my qt project(mentioned in my previous post) with visual studio 2010.
    It is giving an error:the application was unable to start correctly(0xc0150002). Click ok to close the application. And in the debug output window is saying about .pdb files. which is given below.

    'GUI.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
    'GUI.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
    'GUI.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Qt\4.8.4\bin\QtOpenGLd4.dll', Symbols loaded.
    'GUI.exe': Loaded 'C:\Windows\System32\opengl32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\advapi32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\sechost.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\gdi32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\user32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\lpk.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\usp10.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\glu32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\ddraw.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\dciman32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\setupapi.dll', Cannot find or open the PDB file
    'GUI.exe': Loaded 'C:\Windows\System32\cfgmgr32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
    'GUI.exe': Loaded 'C:\Windows\System32\devobj.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\dwmapi.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Qt\4.8.4\bin\QtGuid4.dll', Symbols loaded.
    'GUI.exe': Loaded 'C:\Windows\System32\comdlg32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\shlwapi.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\winsxs\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_a4d6a923711520a9\comctl32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\shell32.dll', Cannot find or open the PDB file
    'GUI.exe': Loaded 'C:\Windows\System32\imm32.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
    'GUI.exe': Loaded 'C:\Windows\System32\winmm.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\winspool.drv', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Qt\4.8.4\bin\QtCored4.dll', Symbols loaded.
    'GUI.exe': Loaded 'C:\Windows\System32\ws2_32.dll', Cannot find or open the PDB file
    'GUI.exe': Loaded 'C:\Windows\System32\nsi.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Qt\4.8.4\bin\QtSvgd4.dll', Symbols loaded.
    'GUI.exe': Loaded 'C:\Qt\4.8.4\bin\QtWebKitd4.dll', Symbols loaded.
    'GUI.exe': Loaded 'C:\Windows\System32\version.dll', Symbols loaded (source information stripped).
    'GUI.exe': Loaded 'C:\Qt\4.8.4\bin\QtNetworkd4.dll', Symbols loaded.
    'GUI.exe': Loaded 'C:\Qt\4.8.4\bin\QtXmld4.dll', Symbols loaded.
    'GUI.exe': Loaded 'E:\Software Dump\OpenGL\GL\GLEW\bin\glew32d.dll', Cannot find or open the PDB file
    The program '[5756] GUI.exe: Native' has exited with code -1072365566 (0xc0150002).

    I assume this may be something to do with VS2010 symbols.Can somebody please help on this?I am new to visual studio 2010?


  • Lifetime Qt Champion

    For system dlls it's normal that the symbols are not found.
    IIRC, it's a library missing error. Do you use 3rd party dlls ? If so, is your PATH updated so that they can be found ?



  • I am using OpenGL libraries like GLEW, GLUT. And also using Boost libraries!.
    And i have already updated the path for QTDIR, GLEWDIR, GLUTDIR, BOOST_ROOT.

    But in my System properties->Environment variables,
    QMAKESPEC variable value is showing: C:\Qt\4.8.4\mkspecs\win32-msvc2010 , is that a problem?

    And my path variable in System properties->Environment variables was updated to:

    C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Program Files\Dell\DW WLAN Card;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\QuickTime\QTSystem;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn;C:\Program Files\Microsoft SQL Server\100\Tools\Binn;C:\Program Files\Microsoft SQL Server\100\DTS\Binn;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn;C:\Program Files (x86)\Common Files\Adobe\AGL;C:\Program Files (x86)\CMake 2.8/bin;%QTDIR%\bin;%GLUTDIR%\bin;%GLEWDIR%\bin;c:\qmake\bin

    Moreover, i have included my GL,Qt and C++ Boost libraries to my project through
    project properties->VC++ Directories->Library Directories also in
    Linker->Input->Additional dependencies

    debugged it, still It is giving an error:the application was unable to start correctly(0xc0150002). Click ok to close the application.


  • Lifetime Qt Champion

    What about boost ? Is it in your PATH ?

    As a side note, you can also play with the PATH variable content in the RUN panel



  • i have updated the path for Boost libraries as well, and debugged my project in vs2010....still It is giving an error:the application was unable to start correctly(0xc0150002). Click ok to close the application.

    Here is my path variable:
    C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Program Files\Dell\DW WLAN Card;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\QuickTime\QTSystem;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn;C:\Program Files\Microsoft SQL Server\100\Tools\Binn;C:\Program Files\Microsoft SQL Server\100\DTS\Binn;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn;C:\Program Files (x86)\Common Files\Adobe\AGL;C:\Program Files (x86)\CMake 2.8/bin;%QTDIR%\bin;%GLUTDIR%\bin;%GLEWDIR%\bin;c:\qmake\bin;C:\Users\Desktop\boost_1_53_0


  • Lifetime Qt Champion

    You can with Dependency Walker, see if gives you some additional informations about missing libraries or something else


Log in to reply