Usual way of installing Qt for Visual Studio is to download already compiled binaries from Nokia website. However binaries for the latest Visual Studio 2010 are not available (on the moment of writing).
This post is a step-by-step guide on how to compile Qt 4.7.1(3,4) with MSVC 2010.
April 5, 2012: As reported by Snouty, 32bit version of Qt 4.8.1 has been successfully compiled by this guide.
December 20, 2011: As reported by Evon, 64bit version of Qt 4.8.0 has been successfully compiled by this guide. To do 64bit compilation, please use Visual Studio x64 Win64 Command Prompt (2010) in step 8. Also please use jom 1.06 and don’t forget to install Service Pack 1 for Visual Studio.
September 16, 2011: Qt 4.7.4 has been successfully compiled by this guide.
August 14, 2011: In order to build Qt for 64 bits just use Visual Studio x64 Win64 Command Prompt (2010) in step 8. Also install Service Pack 1 for Visual Studio 2010 beforehand – it fixes few bugs related to x64 compilation.
July 18 2011: Qt 4.7.3 and Qt 4.8 (beta) has been successfully compiled by this guide. Just replace version number where applicable.
- Visual C++ 2010 contains all necessary SDKs for Qt compilation. However if you plan to use Qt with Phonon you need to install additional software from Qt for Windows Requirements list.
- Install Perl if you are going to compile Qt >= 4.8.0
- Download and extract Qt 4.7.1 Source Code. (Or Qt 4.8.0).
- Copy contents of the folder
qt-everywhere-opensource-src-4.7.1to the directory where you intend to install Qt. In our case this isC:\Qt\4.7.1. - Set up environmental variables
QTDIR=C:\Qt\4.7.1
QMAKESPEC=win32-msvc2010 - Update
PATHvariable to include%QTDIR%\bin - Download the latest version of jom.
- Extract jom files to
C:\Qt\jomfolder - Start Visual Studio 2010 Command Prompt:
Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt. - Run following commands in it (every line is a different command: type it then press
Enter):
cd c:\Qt\4.7.1
configure -debug-and-release -opensource -platform win32-msvc2010
..\jom\jom.exe -j NWhere
Nis number of CPU cores you want to utilize for Qt compilation. Larger is better. - Download and install Qt Visual Studio Add-in.
- Run Visual Studio 2010. Integrate just compiled Qt to IDE using menu
Qt > Qt Options > Qt Versions > Add
Usually compilation takes about 10 hours, but thanks to jom and Intel SSD drive it took only 2 hours 40 minutes on my machine (Windows 7, 64bits)
Remarks
* Jom is nmake replacement for Qt compilation on multi-core CPU. Its parameter -j N allows to setup number of parallel processes for compilation. Number of physical CPU cores is a good choice for N.
** Do not forget to use /d switch if you want to change drive in command prompt, e.g: cd /d d:. Usual cd d: does not work anymore – a little “surprise” from Microsoft.
Contributions
* As Evon pointed in comments, Qt folder has huge size (approx. 7GB) after compilation. One can safely shrink its size by deleting temporary files created during the process. Once compiled Qt doesn’t depend on these intermediate files – and they can be erased without affecting Qt functionality. Run as last command in step 9:
..\jom\jom.exe clean
Note that PDB files will be deleted too.
** Rob provided his compilation script based on nmake with multi-core support.

116 Comments
I followed the steps and it worked like a charm!
Thank you!
Tip: Make sure you have the requirements installed:
(Perl, DirectX SDK & Windows Server 2003 R2 Platform SDK)
http://doc.trolltech.com/latest/requirements-win.html
Thanks for suggestion!
When I give the command \jom\jom.exe -j 4 , it gives error saying that no makefile found. what to do? pl help…!
The command is ..\jom\jom.exe and assumes that jom.exe is in folder C:\Qt\jom. The Makefile can be found in C:\Qt\4.7.3 (or similar).
And make sure you compile it trough the Visual Studio Command promt, i forgot this step and couldn’t get it to work. (Couldn’t find nmake)
Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt
That is 9th step. Maybe I have to stress it more.
Is there or will there be a binary installer for msvc 2010 anytime soon? I am a student and would love to start learning Qt myself, however no matter what I try I get errors. Usually the error is labeled “Return code 2″ or “Return Code 31.” On occasion there is an error with QProcess. This occurs using both jom and nmake. Any information regarding my (granted vaguely described) errors or whether or not a binary installer may be coming out is greatly appreciated. Thanks for your time.
I have no idea about installer for MSVC 2010. Unfortunately I do not know how to solve QProcess errors too. Sorry, I didn’t encountered them.
Well thank you for your speedy response. If I find a solution, I shall let you know.
I had the same problem, but I ran the instructions in Windows Safe Mode Networking and that resolved this problem. No other change. FYI, mine is a Windows 7, msvs 2010, 32 bit, running on i5. Tip: it took me several hours to run “..\jom\jom.exe -j 4″ command. Good luck.
about “return code 2″
see on environmental variables, PATH and on install Qt Visual Studio Add-in 1.1.7
I write PATH – C:\Qt\4.7.1\bin
I do all
but finally in vs doesn’t include qt files
for example QApplication
what I must do?
I make Qt without error
Thanks, help me a lot.
jom does the job well
In instruction 10, is “\jom\jom.exe -j 4″ right after the platform option? Or is it on a new line? Where does the preceding “..” come from?
Also, when I run that command, without this last part (i.e. “..\jom…” part) I get this error:
cpdir: Failure to create “C:/Qt/4.7.1/mkspecs/default”
Couldn’t update default mkspec! Does C:/Qt/4.7.1/mkspecs/win32-msvc2010 exist?
Any idea how to get around this?
Thanks,
@”In instruction 10, is “..\jom\jom.exe -j 4″ right after the platform option?”
No, it is on a new line (press Enter after -platform win32-msvc2010, type ..\jom\jom.exe -j 4 and press Enter again)
I’m trying to compile 4.7.3 for VS2010 using your method. I get to the “configure -debug-and-release -opensource -platform win32-msvc2010″ line and hit enter, but it asks me to confirm the license, so I do, and it starts going without me having chance to enter “..\jom\jom.exe -j 4″. Is this the usual behaviour?
Thanks
Ah NVM, I didn’t realise it had to do some configuration before compilation could begin, it’s going as I type this. Cheers for the great tutorial, I’ve had nothing but problems getting QT working with VS2010, so I’m hoping this works. Cheers for the great tutorial.
Very interesting article , but I was searching to see any success with Static Build of qt. !?
I did my best with 4.8 (new Version from Git repository) but problem is that the ABI is not yet recognized even with latest QtCreator from gitorious repository.
did you had any luck with Static build ?
I believe it is possible to make it fast with nmake if “configure -mp” is used. In this case multicore features of jom have no bonuses compared to standart nmake.
(Default configure key is -no-mp which means no use of multiple processors for compiling with MSVC)
Hi, i am using visual studio 2010, why am i unable to find visual studio tools? any help pls? what i have is only visual studio tools for office
Hi,
I’ve been trying to build Qt using MS VS 2010, and running into failures.
I’ve tried using nam and jom, and both have failed.
I’ve set the environment variables for QTDIR, QTMAKESPEC and PATH per my
installation of Qt (in D:\4.7.3).
I’ve included the output from jom, below.
Can someone help?
thanks,
-Confused
——————————————————————–
d:\Qt\4.7.3>..\jom\jom.exe -j 4
jom 1.0.5 – empower your cores
Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555
Copyright (c) Microsoft Corporation. All rights reserved.
testcon.idl
ocidl.idl
oleidl.idl
objidl.idl
unknwn.idl
wtypes.idl
basetsd.h
guiddef.h
oaidl.idl
servprov.idl
urlmon.idl
msxml.idl
oaidl.acf
ocidl.acf
Microsoft (R) 32b/64b MIDL Compiler Version 7.00.0555
Copyright (c) Microsoft Corporation. All rights reserved.
testcon.idl
ocidl.idl
oleidl.idl
objidl.idl
unknwn.idl
wtypes.idl
basetsd.h
guiddef.h
oaidl.idl
servprov.idl
urlmon.idl
msxml.idl
oaidl.acf
ocidl.acf
command failed with exit code 31
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
d:\Qt\4.7.3>
For an almost always guaranteed compile, download the binary release for VS2008 from qt.nokia.com
I’m developing in VS2005. Currently rebuilding my 4.7.1 build (got an itchy uninstall finger). I’m about to do this for the 4.7.3 update.
Why? it comes with DLL forms and the source code for all the 3rd party packages, which allows for it to link correctly. You won’t have to worry about the 3rd party packages being the wrong version for your build, either.
to do this, here are the appropriate addendum for this article (also,I’m directing to the 4.7.3 build, but everything should be the same):
Follow OP’s first two steps.
3: Download Qt libraries 4.7.3 for Windows (VS 2008, 228 MB)
4: Execute the installer. Notice that Qt will be installed in
C:\Qt\4.7.1continue on with step 5 from above.
Thanks for the information (it’s been a few months since I had to build Qt).
flyingcadet
Hello Confused!
I had the same problem as you have. I set also the environmental variables, as mentioned above, and I got the same errors like you.
(By the way – my system is Windows 7, Visual Studio 2010 Ultimate, Qt 4.7.3 – could be important, maybe.)
Ok. I deleated every environmental variable concerning Qt, started the VS2010 comm. prompt again. When the comm. prompt is open, one can see in the most upper line that there is no error – everything about Visual Studio 2010 was loaded.
Next step is to configure Qt with (my choice)
configure -platform win32-msvc2010 -opensource -no-qt3support
After the configuration, nmake! I am compiling it right now without problems. Few hours later, Qt will be compiled. So, maybe now or not one has to set the variables. I will try it first without setting the variables. If any problems occure there, I will do further steps.
I hope, that I was able to help you/anyone.
Best regards
Very well written instructions, and that is a rare thing these days. Nice job!
A follow up comment. I believe your instructions will produce a 32 bit Qt build since you are stating to use [Visual Studio Command prompt] vs the x64 command prompt. Is this correct? The way you have it written appears to work, but it is causing all kinds of problems with VTK, which is expected 64 bit Qt libs. I tried simply using the x64 command prompt but keeping all other steps the same. The jom is failing for x64. Ideas?
Yes, you are right, this is 32 bits build.
And yes, you are correct again – in order to compile x64 binaries just use
Visual Studio x64 Win64 Command Prompt (2010).However, make sure that:
1. You have installed Service Pack 1 for Visual Studio 2010. Otherwise it won’t build x64 projects correctly.
2. You do clean build. Copy Qt sources (from downloaded zip file) to another directory and compile it there for x64.
I’ve just compiled Qt 4.7.3 for x64 platform this way – no problems with jom appeared.
Test applications run nicely too. Dependency Walker re-assures that binaries are indeed x64 binaries.
Hi!
first of all thanks for this!
I would ask you if I should change something in the instructions in case I want to build the 64bit version.
I work with windows 7, VS 2010 with SP1, and Qt 4.8.0
Thank you very much.
Just use
x64 Win64 Command Prompt. No other modifications are needed. I’ve compiled 4.7.3 without problems for x64. I’m sure 4.8.0 is similar.Thank you for the prompt reply. I tried to build the 4.8.0 but I had some problems/errors with jom, probably because I’m working with windows 64bit. So I moved to the 4.7.4 and it worked fine.
Thanks again!
I really need help….
After I run: configure -debug-and-release -opensource -platform win32-msvc2010
I get these messages:
Creating qmake…
execute: File or path is not found (nmake)
execute: File or path is not found (namke)
Cleaning qmake failed, return code -1
As a result when I try to run ..\jom\jom.exe -j 4 I get:
Error: File Makefile doens`t exist.
I am using VS 2010 Command Prompt. The weird thing is when I type in nmake he doesn`t have a clue what it is. Could I be missing something…?
My only guess your VS 2010 is not properly installed.
I’am having the same problem exactly as you. I’m running Windows 7 64-bit BTW. Did you solve your problem?
I suspect VS Commnad Prompt Tools are not properly installed on your system.
Try to run vsvars32.bat in a command prompt. It is located here:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
Under step 9, is the third line supposed to be part of line 2? Because it appears that I never had the option to use Jom? I hardly ever use the command prompt so if line 3 was supposed to be part of line 2 that needs to be clarified. It just started doing stuff right after I hit the enter key after msvc2010.
On step 9 every line is a different command. I’ve added clarification – thank you for your feedback.
Compilation with jom brought up a linker error. Compilation with nmake was successful!
Worked like a charm!
I am trying to compile and run these samples http://qt.gitorious.org/qt-solutions/qt-solutions/trees/master/qtwinmigrate but failing. Believe it may be because have to compile qtwinmigrate with Visual Studio. Any pointers on how to do that?
Thanks so much, Kurt
I’ve followed all the steps, and now I’m wondering about the last one – how to integrate? In Qt menu I have only: ‘Launch Designer’,'Launch Linguist’,'Open QT Project File…’, and ‘Qt Options’ available. Is this ok?
Add compiled Qt to Qt Options > Qt Versions.
Hi Pavel,
These instructions are perfect – I have been able to build Qt and create projects via VS 2010 with ease.
I do have one question: Due to project requirements on deployment, I built Qt as static instead of shared (you haven’t specified it in your configure parameters, but the default setting is shared). This way, I don’t have to deploy the Qt dll’s as well.
However, I observe that the release libraries are built with the -MD flag (Multi-threaded DLL). How do I force it to use the -MT flag instead? The configure script seems hardcoded to use this flag when -static is passed for configure.
Was hoping you might have a quick answer here, would rather not read through a 5000 line config script…
Thanks!
Oh and one other thing – I’d like to change it to use “treat TCHAR as a built-in type” – again the script seems hardcoded to always pass FALSE for that flag (“Z:wchar_t-”).
Any thoughts?
You can change compiler options directly using file
Qt-folder\mkspecs\win32-msvc2010\qmake.conf.Here are few related options from the file:
As for static vs. shared – I would advise to use Qt DLL. As far as I understand it is the most correct and safe way of using LGPL library in commercial application.
Wow, that was fast – thanks!
Wrt static/shared – The source of my application would be redistributed under either GPL 2 or LGPL 2 – would that still indicate using the DLL’s? My understanding is if I also make my app open source, static linking is fine.
@”My understanding is if I also make my app open source, static linking is fine.”
Yes, I think so too.
I have installed Qt SDK. I did n’t find any specific QTDIR folder.
In the QtSDK/Desktop/Qt/4.7.4/ folder I found mingw and vs2008.
What folder should i mention for QTDIR
Hi!
I had a couple issues, but by the fourth time I finally made it.
What helped was redoing everything on a freshly unpacked Qt Source Code, also I did run “vcvarsall.bat” from MS Visual Studio 2010 which I think helped the issue of some errors (return code 2 maybe). Jom is really great!
Thanks!
I am glad you solved all issues – congrats!
Great instructions! I followed them to successfully build 64bit Qt 4.7.4 on my Win7 Pro x64 machine. My version’s usable both within Qt Creator 2.3.0 (32bit) and Visual Studio 2010 (SP1). Both IDEs can build 64bit applications! It’s definitely worthwhile to update Visual Studio to Service Pack 1 prior to compiling Qt, as my builds continued to fail until I updated.
Here’s my config, for variety:
configure.exe -debug-and-release -opensource -platform win32-msvc2010 -no-qt3support -qt-gif -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg
I have noticed that the Qt folder is enormous after compiling. I’d like to delete the intermediate files that bloat the folder while leaving the compiled 64bit libraries intact. I read here and here about 3 options with nmake (clean, confclean, distclean), but I’m unsure what exactly the difference is between each.
As I understand it, one deletes the intermediate files, one deletes the intermediate files AND the compiled libraries, and one deletes the intermediate files AND the source code… but which one’s which? Can you shed some light on the differences between the 3 options?
I also haven’t found anything about using jom to “clean” my Qt build folder. Does jom have an alternative to any/all of the nmake ___clean options?
I appreciate your feedback, thanks.
You are right, Qt folder is pretty big after compilation since many temporary files were created in the process.
Once compiled Qt doesn’t depend on these intermediate files – and they can be safely erased without affecting Qt functionality.
Run as last command in step 9:
..\jom\jom.exe cleanI’ll added this to the manual. Thanks!
Thanks for the tip! Unfortunately, running jom’s clean happens to also cause the VS2010 compiler to throw LNK4099 warnings because of vc100.pdb being deleted in all of the Qt source libraries. I believe in fixing errors, not ignoring them. Do you know of a way to prevent this?
Here’s the error text for a simple project:
qtmaind.lib(qtmain_win.obj) : warning LNK4099: PDB ‘vc100.pdb’ was not found with ‘qtmaind.lib(qtmain_win.obj)’ or at ‘C:\dev\programs\AddressBook\vc100.pdb’; linking object as if no debug info
“Warning” is what it is – warning, not error.
Debug information (pdb) for Qt is needed only in rare cases (e.g. for debugging Qt itself) and not crucial for apps development – you can debug them as usual.
Just for analogy – MS doesn’t supply pdb files for Windows kernel modules
which is intensively used in any application.
Nonetheless this is not the “error” preventing development for Windows – right?
PDB files are of the largest size among temporaries generated by compiler. If you keep them – no space saving will be available.
Thanks for the comment. I’ve messed around with it since my last post and you are correct in saying that that warning has no apparent ill effect on the Qt program. I’ll have to disable that warning at some point when I get tired of seeing it.
Additionally, the 64bit Qt also works in the 32bit Qt Creator IDE (v2.3.1 on a clean install, NOT the Sept 1, 2011 SDK). Just add it to your list of Qt versions in Tools -> Options. To debug your 64bit programs on a PC, you have to download and install the free 64bit Debugging Tools for Windows as instructed on the official Nokia site here and here.
I was relieved to learn that I didn’t have to compile a 64bit version of Qt Creator to do 64bit development.
Good news, Evon! Thanks for the info.
I prefer to use MSVC 2010 IDE + Qt Visual Studio Add-in + Visual Assist X combination. IMHO Qt Creator IDE slow and immature, but it has major advantage of being free.
I guess you already own Pro version of VS 2010 (since you can compile x64) – so why don’t you use it for development?
P.S. I’m impressed by the work of WatershedSciences.com company. I worked on similar projects here in Japan for AeroAsahi company. I developed compression algorithms for data from laser measurement & huge aerial images. Earth is pretty small after all.
The newer versions of Qt Creator are pretty fast and the auto-generated code from integration of Qt Designer into Qt Creator can be helpful. I generally like to code my own UI with Qt and avoid Qt Designer altogether, but I’m still playing with it once in a while.
I haven’t toyed much with the VS Add-in yet since Qt Creator is simpler to use for a casual coder such as myself.
Interesting that you’ve heard of us over in Japan! We’re always interested in new opportunities.
I just did a little work over there this summer for my research with Oregon State Univ as a tsunami-related collaboration with BRI. Small world.
Awesome tutorial, very concise and well written! I just built from scratch with MSVC2010 in the Visual Studio x64 Command Prompt and it generated the proper qmake for x64 development (as you pointed out Pavel, no adjustments to the tutorial are needed). If I had read the prereqs a little closer I would have gotten it on the first try.
However I am still curious about this (from Evon):
“Additionally, the 64bit Qt also works in the 32bit Qt Creator IDE (v2.3.1 on a clean install, NOT the Sept 1, 2011 SDK). Just add it to your list of Qt versions in Tools -> Options”
I had tried this with the binaries from Qt and could not set my x64 compiler in this way because I did not have the proper qmake (and thus Qt greys out the x64 toolchain in the projects tab). Can you give me some suggestions as to why this was happening? I guess I don’t know much about the difference in the qmake files for x64 and win32 compilers. My computer config was the same before I built and when I tried this last (I had installed all the build prereqs before this). Thanks.
@Ryan:
I’ve noticed that Qt Creator saves its Qt4 settings separate from its installation so that you can share your toolchains between multiple QtC installations. There might be some sort of corruption between versions. More likely, though, one of the links in your toolchain is broken.
First, I’d check to make sure that you’re targetting the proper qmake. If you move your build directory after following Pavel’s steps, then you will break the toolchain even if you’re targetting the correct qmake. For me, that’s
C:\dev\qt\4.7.4_x64_msvc2010\bin\qmake.exe
Note that this is the exact same directory where I built my 64bit version of Qt—I’ve never moved it.
Second, make sure you create a new toolchain under Tools->Options->Qt4 rather than editing an existing one to prevent corruption. Click down the Details and make sure you click [Build All] to construct your toolchain. If you’ve already done that, make sure it’s pointing to the correct directory and using the “Microsoft Visual C++ Compiler 10.0″ (or whatever version you have installed).
Third, I deleted all of my *.pro.user files for the projects that I wanted to build in 64bit and recreated the build configurations, just to make sure that I had clean projects going. I doubt this is your problem since it won’t even enable your toolchain, but you never know.
PS—Pavel, I linked your site from Nokia’s wiki and overhauled their instructions since their 64bit compilation instructions were laughable. You might see a traffic boost.
Evon,
Thank you for your valuable advises and for spreading the word!
Nokia’s wiki is a top referrer to the page for the last 7 days.
Hello,
thanks for the great tutorial. Everything worked well, but after roundabout 1:30 hours of compiling, I got the following error :
moc_helpgenerator.cpp
link /LIBPATH:”c:\Qt\4.7.1\lib” /LIBPATH:”c:\Qt\4.7.1\lib” /NOLOGO /INCR
EMENTAL:NO /SUBSYSTEM:CONSOLE /MANIFEST /MANIFESTFILE:”tmp\obj\release_shared\qh
elpgenerator.intermediate.manifest” /OUT:..\..\..\..\bin\qhelpgenerator.exe @C:\
Users\Sascha\AppData\Local\Temp\qhelpgenerator.exe.3288.1030.jom
LINK : fatal error LNK1104: Datei “..\..\..\..\bin\qhelpgenerator.exe” kann nich
t ge÷ffnet werden.
command failed with exit code 1104
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
c:\Qt\4.7.1>
“qhelpgenerator.exe cannot be opened”… and the compiling stopped. Someone got an idea whats the matter about that?
Thank you very much for your help!
Sascha
Hi, Sascha!
It seems something wrong with your
PATH– check 5th step in tutorial.BTW, try to compile latest version of Qt 4.7.4 – no reason to use old one 4.7.1.
I had an issue where the build failed in the middle on my 64 Bit Windows 7 Pro Laptop using Developer Studion 2010 Pro. I can’t remember the exact error but it seems similar to this one. Running the command prompt as an administrator solved the issue.
Also to clarify, I was building the 32 bit version using the x86 command prompt.
Pavel, great job,
Oli
Jom is ok, but you can just use the -mp switch with nmake.
Here’s my script to do an out of source build on the latest git located in C:\Qt\qt-git-build
@ECHO OFF
rmdir /Q /S C:\Qt\qt-git-build
mkdir C:\Qt\qt-git-build
cd C:\Qt\qt-git-build
..\qt-git\configure -opensource -mp -qt-zlib
nmake
nmake qdoc3
editbin /STACK:0x200000 bin\qdoc3.exe
nmake docs
nmake install
nmake clean
cd ..
Just open up a Visual Studio x64 command prompt and run the batch file. This also builds the docs, the editbin command fixes a stack overflow that none of the developers seem to care about because it only shows up in 64-bit windows. The nmake install copies the header files over instead of dummy files to the qt-git directory, and the clean gets rid of the temporary files. This builds a nice copy of Qt that you can move from computer to computer, albeit pretty large.
Our development environment requires x64 because of our large datasets, and I’m already using functions that were introduced in 4.8.0. This will have to do until the people at the qt-msvc-installer google code page upload 4.8.x version of their installer.
@Evon: The Qt Creator which you download from the Nokia website has Qt built statically. Check the ‘about’ section and you’ll see it may be using a different version.
The whole process takes about 2 hours with an i7, no jom necessary.
Thanks for great info and for sharing your script!
I’ve added link to you comment on the page.
Just to note – Qt compiled by my instructions can be moved from one computer to another without any problems too.
.
Webpage of qt-msvc-installer says about Visual Studio 2008 support only. As for docs – I use online help – it is always up to date and broadband is spoiling
Worked like a charm, even if I launched ..\jom\jom.exe -j 4 having dual-core machine.
Pls help. For my compilation I used QMAKESPEC=win32-msvc2010, then configure -debug-and-release -opensource -platform win32-msvc2010.
I am on x64 machine, so I used Visual Studio x64 Win64 Command Prompt for whole process.
Now when trying to launch simple app created from VS wizard in Debug configuraion Win32, I got:
>QtGuid4.lib(QtGuid4.dll) : fatal error LNK1112: module machine type ‘x64′ conflicts with target machine type ‘X86′
So the Qt is builded for x64 even if win32-msvc2010 was set? Because of the x64 command prompt? Or am I wrong? My orded was to develop x86 app onx64 system. Thanks.
You need x86-Qt to create x86 applications even using x64 operating system for development.
So, compile Qt in x86.
Yes, when you use x64 command prompt Qt is compiled to x64, despite win32-msvc2010 setting.
Yippee! It works. Thanks a lot for reply.
Visual Studio Command Prompt makes it x86, Visual Studio x64 Win64 Command Prompt (2010) makes it x64.
First time I tried the x86 VS cmd prompt there was error during compilation. This was the reason why I installed Service Pack 1 for Visual Studio 2010 and used x64 cmd prompt instead (..assuming that x86 VS cmd prompt is not working on my x64 machine) Bad idea, it works. But without SP 1 there are errors during build of Qt 4.7.4
If I may, you probably should add a comment in the steps or just below about the fact that win32-msvc2010 is for both: 32 & 64 bit compiles.
Thanks a lot! Works great!
First Thanks for your help (I dont understand why there is not similar ‘official’ help on QT web page …. )
I have two problems-questions….
First: Have I to build a debug_and_release QT ? Now, I see how release and debug versions are created. (###.dll /lid and ###d.dll /lib )
I’m a bit confused…. The ### files are ‘pure’ release versions and ###d. ‘pure’ debug versions ? What are the difference with a ‘debug_and_release’ build ?
Second:
On release mode I can compile my app but on debug mode I have a link error: cannot find QtOpenGLd4.dll.
If I look at my /bin folder I see there is a #4.dll / #4.lib / #4d.dll /4d.lib for every qt library except QtOpenGLd4.dll. (I have only the release version ) What is happen ? Any idea ?
Thanks .
Thanks alot, worked fine for me at last. Was trying to get qt running for VS10 for quite some time, but always gave up in between, because i was frustrated that it spit out, for me unresolvable errors during compilation of my files…
Up to now i think this solution works
For such a big project as QT the instructions give on their website are a joke, its too hard to get it running if you aren’t a experienced computer science guy.
So thank again for this help!
I’m getting a bunch of errors during compilation “warning C4100: unreferenced global data”. So far, I’ve only noticed it during the section where its compiling javascript, but I haven’t been following it the read out closely, so it might have occurred during other parts as well.
Do you know what might cause this issue? Also, since its still compiling, and most of it seems to be compiling correctly, do you know if might be a critical problem when I actually try to use the libraries?
Thanks
It is not “error”, it is “warning”.
C4100 is not critical (otherwise it would be reported as “error”), it just means there is global variable defined but not used.
I would appreciate it if you put the description of the -j parameter inline with the instructions.
Done
I followed the directions to a “T” and having problems with the last stage of building. Everything compiled okay though but the build stopped.
I have Win7 X64
VS 2010 (Ultimate)
Every time I run the,” ..\jom\jom.exe -j 5″, It stops in a different area. If I run it again, it will pass this error and have another manifest issue.
I even tried to open the VC CMD window in Admin mode, didn’t help.
link /LIBPATH:”d:\Qt\4.7.4\lib” /LIBPATH:”d:\Qt\4.7.4\lib” /NOLOGO /INCREMENTAL:
NO /MANIFEST /MANIFESTFILE:”tmp\obj\release_shared\testcon.intermediate.manifest
” /SUBSYSTEM:WINDOWS “/MANIFESTDEPENDENCY:type=’win32′ name=’Microsoft.Windows.C
ommon-Controls’ version=’6.0.0.0′ publicKeyToken=’6595b64144ccf1df’ language=’*’
processorArchitecture=’*'” /OUT:release\testcon.exe @C:\Users\John\AppData\Loca
l\Temp\testcon.exe.61547792.jom
mt.exe -nologo -manifest “tmp\obj\release_shared\testcon.intermediate.manifest”
-outputresource:release\testcon.exe;1
mt.exe : general error c101008d: Failed to write the updated manifest to the res
ource of file “release\testcon.exe”. Access is denied.
command failed with exit code 31
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
D:\Qt\4.7.4>
Does anybody know why I seem to be having this problem? The whole compile process seems to have worked, just the manifest area.
Thanks!
John
Floating “c101008d” error is known problem of VC (not related to Qt) and was reported to MS few times (google for it).
Unfortunately no solution is provided yet. All I can suggest is to install latest service pack for VC, try to turn off antivirus protection during compilation or try to compile Qt on another PC.
Do you really have 5 cores? I’m taking a shot in the dark here, but that might affect your build if you only have a quad-core processor.
I second Pavel’s suggestion to make sure you have SP1, btw. I was experiencing similar behavior until I updated my VS2010.
I have a quad. Good rule to compile is N+1.
I have installed SP-1.
The issues I am having seem to be file permissions.
If you build under “admin” then only antivirus (or other security software) could mess up access to files.
I’m getting 4 updates for 2010. Hope this works.
If this doesn’t work, then I may just get the pre-compiled binaries from Nokia and use VS2008.
I just want to get QT working fast and build a sample project.
Thanks for all the help.
I will post anything eventful.
Thanks,
John
Figured it out. Thanks to the advice of turning off my anti-virus, it built fine.
I searched other sites for same error code and most had to do with AV. Had to do with filenames or combinations of file name being create then copied; then AV would block read access for a short period of time and return “bad handle” back to caller.
Thanks all, make sure to turn off AV no matter which one you have if goofy problems. To bad this is an issue… Only have to do this once in a while though and can disconnect from internet when building future bins.
I have AVG and found other AV’s out there that are causing same issue. Apparently with some file names being created and copied too soon, AV’s pick up on this and block access.
Thanks All,
-John
Hi, thank you very much for your guide, I have one question, If I already have a set of Qt libraries that I know where compiled with msvc, how can I know if they where compiled for x86 instead of x64?. Thanks in advance
You can use Dependency Walker for this: http://www.dependencywalker.com/
I have the following error:
Any idea how to finish compiling?
Try to turn off antivirus software, which can block access to files.
I got the same error even with the antivirus being disabled. comapp.idl is not generated for some reason, I searched for it in the msvc2010 folder
Hi Pavel!
I have a very similar error as Andrei: “IDL generation failed trying to run program release\comapp.exe”
So the debug part seems to be OK.
I also disabled AV, but with no success. Do you have any idea what is wrong?
I will try again with the network cable unplugged…
I forgot to add:
I got the following message (window) when it stopped compiling:
“The procedure entry point ??0QVariant@@QAE@HPBXI@Z could not be located in the dynamic link library QtCore4.dll”
It has finished the compilation normally with nmake.
Thank you Grega for information, I think latest jom might has a bug.
I had a similar problem while compiling examples. It told me that the ??0QVariant@@QAE@M@Z did not exist. Yet, looking inside the QtCore4.dll file, it exists. So I’m not too sure why it could not find it.
Since that happened in the examples, everything else worked so I guess I have a working version of Qt now.
Thank you for the instructions!
Alexis
Okay! Got it!
The computer is from work and they installed another tool that makes use of Qt 4.x as well. Problem is, that other tool is compiled and linked with an older version of Qt (4.5.2). So whenever a tool is loaded, it may instead load that other version because it was installed in a C:\windows\WOW64(something) folder which is automatically scanned by the operating system (in other words, changing your %PATH% variable has no effect.)
In other words, my compile did work just fine, only that other version of Qt 64bit is in the way!
Speaking of that, I also noticed that Perforce was making use of Qt. But at least they keep those libraries in their own personal bin folders.
Thanks again for the info on this page!
Alexis
Thanks Alexis for sharing your solution!
FYI, I just successfully compiled a 64bit version of 4.8.0 using msvc2010 SP1 on my Windows 7 x64 machine. It works with Qt Creator 2.3.1; I haven’t used the VS add-in (which Nokia no longer supports, btw). I used jom 1.06 for my compile again since people have been complaining about the latest version having bugs.
Thanks Evon, I’ve updated the post. They’ve released 4.8.0 on Qt Developer Conference in Tokyo, which I was lucky to attend
.
Well, I haven’t been so succesfull. Had to alter .pro file not to include examples and demos, which didn’t compile. Qt 4.8, win 7 x64.
Apart from that, the VS addon still works – but is unable to invoke qt designer.
Previously created projects compile fine.
Hi, I have got a problem when I compile 64bit Qt 4.8.0 in VS2010, windows 7 (x64).
I followed the step you provide.
1, I download 4.8.0 using the link you give, and put it in E:\Qt\4.8.0
2, Environment varible and path were set correctly.
3, jom106 is downloaded into e:\Qt\jom
4, in Visual Studio x64 Win64 Command Prompt (2010), I change the dir to E:\Qt\4.8.0
configure -debug-and-release -opensource -platform win32-msvc2010
..\jom\jom.exe -j 8
after compilation, it says
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
And the file’s size now is only 4GB+, not 7GB.
what is this problem?
Thanks in advance.
Heng
Try to: (1) turn off your antivirus; (2) install SP1 for visual studio if you’ve not done it yet.
Hi folks,
I got the following error while trying to compile Qt 4.7.1:
IDL generation failed trying to run program release\openglax.exe!
midl tmp\obj\release_shared/openglax.idl /nologo /tlb tmp\obj\release_sh
ared/openglax.tlb
Processing tmp\obj\release_shared\openglax.idl
openglax.idl
c1 : fatal error C1083: Cannot open source file: ‘tmp\obj\release_shared\opengla
x.idl’: No such file or directory
midl : command line error MIDL1003 : error returned by the C preprocessor (2)
jom: C:\Qt\4.7.1\examples\activeqt\opengl\Makefile.Release [release\openglax.exe
] Error 1003
jom: C:\Qt\4.7.1\examples\activeqt\opengl\Makefile [release-all] Error 2
jom: C:\Qt\4.7.1\examples\activeqt\Makefile [sub-opengl-make_default] Error 2
jom: C:\Qt\4.7.1\examples\Makefile [sub-activeqt-make_default] Error 2
jom: C:\Qt\4.7.1\Makefile [sub-examples-make_default-ordered] Error 2
I did try to compile using ..\jom\jom.exe -j 2 on a computer with the following configuration: Intel(R) Core(TM)2 Duo CPU E(%== @ 3.16 GHz 3.16 GHz
Thank you for your help in advance,
Boba
It seems like something wrong with file access rights – similar problems happened before. Try to turn off your antivirus.
Hi, will this tutorial work for Visual C++ 2010 Express? I want to be able to use the IDE for Qt development. I can’t seem to find any free version of Visual Studio 2010. Please respond and thanks in advance.
Qt Visual Studio Add-in won’t work with VC 2010 express. Without this add-in it will be very difficult to develop Qt applications using VC. Your best bet is Qt Creator.
Makefile not found when trying to jom -j 2?.Where to get it? Please help, 4.8.0
Did you run
configurebeforejom?Yes, run configure -debug-and-release -opensource -platform win32-msvc2010, jom is last version 1010 or so on, copied to 4.8.0\jom and to c:\Qt\jom. Tried nmake also. короче ничего не помогло.
I have same problem.
I write “qmake” after configuration and it fix jom makefile error
Iam not sure that it is right but it works
Thanks a lot for this tutorial. I just successfully compiled a 32bit version of 4.8.1 (Visual Studio 10 Ultimate, Win 7, i5). Took me round about 4 hours, but everything works now
Thanks for letting me know.
If everyone gets “no makefile” error when running jom, you probably don’t have Perl and so it cannot run the configuration correctly, I’m not quite sure if this is the solution, but go to the QT directory\bin\ and delete the syncqt.bat.
After that run the configure …. again. Then now jom should work.
I used these instructions to compile QT 4.8.1 in both 32 and 64 bit on Windows 7. Both versions compiled without problems in about 45 minutes each using an i7 chip and all 8 virtual cores. The only hitch was that I had to install Perl first; I used ActiveState Perl from here http://www.perl.org/get.html and it worked with all the default settings.
Thank you for these instructions!! I’ve looked at a dozen other “tutorials” and I failed with them. This is so clear and easy to follow. It saves many hours of headaches.
Thank you Patrick for your feedback!
Hey thanks for this awesome tut! Tried many others and they caused headaches and many upon many wasted hours.
Used it for building 4.8.1 libraries with msvc2010 in x86 vs cmd. Works perfect.
Thanks again, you have saved many people lots of time.
All the best