This post is a step-by-step guide on how to compile Qt 4.x.x with MSVC 2010.
Although we use Qt 4.7.1 as an example (for historical reasons), you can also find suggestions on building newer versions of Qt by MSVC 2012 and even by Intel Compiler for both platforms x86 and x64. All kudos go to numerous contributors, who spend their time to do all the tweaking and testing (see updates below).
In particular there are instructions on how to build Qt 5 for x64 platform contributed by Vincenzo Mercuri.
Updates
December 19, 2012. Vincenzo Mercuri informed that he have compiled Qt 4.8.4-x64 by the guide. Also he shared his instructions for building Qt with Intel C++ Compiler into static library.
November 4, 2012: As reported by Mike Pelton, whatnick and Borislav Stanimirov, 32 & 64bit versions of Qt 4.8.3 have been successfully compiled by this guide, by both Visual Studio 2010 & 2012. Be aware that Qt might not be adjusted yet for Windows 8 (as reported here).
June 4, 2012: As reported by Wenqing, Qt 4.8.2 has been successfully compiled by this guide.
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.
Build instructions
- Visual C++ 2010 contains all necessary SDKs for Qt compilation. However if you plan to use Qt with Phonon you need to install DirectX SDK first.
- Install Perl if you are going to compile Qt >= 4.8.0
- Download and extract Qt 4.7.1 Source Code. (Qt 4.8.0 or Latest snapshot).
- Copy contents of the folder
qt-everywhere-opensource-src-4.7.1
to 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
PATH
variable to include%QTDIR%\bin
- Download the latest version of jom.
- Extract jom files to
C:\Qt\jom
folder - 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
N
is 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 10:
..\jom\jom.exe clean
Note that PDB files will be deleted too (the files are rarely needed, only for debugging of Qt itself).
** Rob provided his compilation script based on nmake
with multi-core support.
223 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).
Hello,
Will the above steps remain same if I have to build QT4.8.6 with visual studio 2010 on windows 10 (64 bits) ?
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.1
continue 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\
I had this message. It was a simple mistake of mine. I wrote “set PATH=%QTDIR%:%PATH%” (with a colon) instead of “set PATH=%QTDIR%;%PATH%” (with a semi-colon).
The result was that the previous path was corrupted, and nmake was not found.
Thanks for this useful tutorial
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 clean
I’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 :-).
When you say
what do you mean exactly by “moved from one computer to another”. Can you put it on any hard drive in any directory and use it in QtCreator by adding it manually? Because that doesn’t work for me, as the different paths to bin, lib, etc.. seem to be hardcoded once you compile.
Did I miss anything?
If anyone is still interested, to make Qt really portable you can create a file called “qt.conf” and put it into the “bin” folder beside the qmake.exe. The only thing it needs to contain is these two lines:
[Paths]
Prefix = ..
This will instruct qmake to search for libs, includes etc. in the directory one level up so instead of the path that gets hardcoded into qmake at compilation it will then use the relative one specified by qt.conf. This makes it possible to move it to wherever you want.
This is not very well documented and it took me a long time to figure it out so I thought it might be helpful for some people.
Sounds like a really slick workaround. I’m definitely going to give this a try!
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.
1) Install extension for 64bit
2) “C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd” /x64
3) All next steps are the same…
Makefile not found when trying to jom -j 2?.Where to get it? Please help, 4.8.0
Did you run
configure
beforejom
?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
Hi,
I followed your method but I got the following error
“Module Machine Type IA64 conflicts with target machine type x86”
I did the configuration as per your writing, with the platform as win32-msvc2010.
I am using Windows XP 32-bit and I am running the normal “Visual Studio Command Prompt (2010)” ( different from the two other options – “Itanium Cross Tools Command Prompt” and “x64 Cross Tools Command Prompt” )
Any help would be appreciated.
Thanks,
Pankaj.
thanks for the guidance, I used these steps to build 4.8.2 successful. But I met one issue in my first build:
\src\3rdparty\webkit\Source\WebCore\platform\DefaultLocalizationStrategy.cpp, Line 327,
in this line there are two strange double quotation, I changed them to
return WEB_UI_STRING("Look Up \"<selection>\"", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));
truncatedStringForLookupMenuItem(selectedString));
Thanks for sharing! I followed this days ago and I did success in compiling. However, since I had changed the cflags by incident, I have to compile it again. But when I pulled the latest Qt version from Git and tried to compile, it gave the following errors:
Running syncqt...
Creating qmake...
cl -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch -c -Fo./ -W3 -nologo -O2 /MP -I. -Igenerators -Igenerators\unix -Igenerators\win32 -Igenerators\mac -Igenerators\symbian -Igenerators\integrity -IE:\QT\qt\include -IE:\QT\qt\include\QtCore -IE:\QT\qt\include -IE:\QT\qt\include\QtCore -IE:\QT\qt\src\corelib\global -IE:\QT\qt\src\corelib\xml -IE:\QT\qt\mkspecs\win32-msvc2010 -IE:\QT\qt\tools\shared -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NODLL -DQT_NO_STL -DQT_NO_COMPRESS -DUNICODE -DHAVE_QCONFIG_CPP -DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQT_NO_PCRE -DQT_BOOTSTRAPPED -DQLIBRARYINFO_EPOCROOT -DQMAKE_OPENSOURCE_EDITION E:\QT\qt\qmake\project.cpp
project.cpp
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(2811) : error C2146: syntax error : missing ';' before identifier 'rcBound'
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(2811) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(2811) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wingdi.h(2857) : error C2146: syntax error : missing ';' before identifier 'otmrcFontBox'
...
Can someone tell me what I was doing wrong? In the last time I just removed UNICODE cflag and it compiled ok for most of the codes.
Hi,
Thank you very much for very useful information.
I followed your steps and it looks like it worked.
However, I am using QT in an open source C++ project that I would like to debug, however when I build the solution in MSVS2010 in debug mode I get this error:
1>qtmain.lib(qtmain_win.obj) : error LNK2038: mismatch detected for ‘_ITERATOR_DEBUG_LEVEL’: value ‘0’ doesn’t match value ‘2’ in audiomixerboard.obj
It looks like the QT is not compiled with debug information? Is that true? I thought using:
configure -debug-and-release -opensource -platform win32-msvc2010
Provides debug information as well.
I appreciate any help on this.
100% this tutorial!!!! Congratulations!
To the OP of this blog post. Some users probably use the parameter ‘-dont-process’. This avoid creating new Makefiles necessary for compiling(jom or nmake needs them). There is a solution in the one of the forum out there that suggest to use gmake and create a new Makefile from the projects.pro file. But this is badly wrong!. The makefile should be created after the configure… command. If there is no new Makefile than some of your parameters are wrong or you make something wrong(like using the -dont-process parameter, which should be removed afaik). I’ve tested it with Qt 4.8.2.
Regards
I am trying to compile QT library into my visual studio 2010 program. I have a window 7, 64 bit operating system with a celeron processor. I must have a 32 bit visual studio because when opened my command prompt within the visual studio, the title bar says x86. I thought I had a 64 bit visual studio 2010 but I guess I actually have a 32 bit software installed.
I am very confused as to which version of QT library, Pearl, and jom to download since I have a window 64 bit operating system ? Due to the enormous download time, I ended up downloading the 32 bit QT 4.8.0 linked to this website. I also downloaded jom 1_0_0_6, which I assume is version 1.o6 as recommended if using QT 4.8.0. I also downloaded 32 bit strawberry pearl and installed service pack 1 for visual studio 2010.
I did not have any problems configuring QT within visual studio 2010.
My problem started when I run nmake to build the library. I issued the ..\jom\jom.exe -j N setting N=1 during the first nmake because I do not have multi-core cpu. After at least 15 hours, my computer was still compiling and generating code. It may even have been 20 hours so I just shut it down and deleted the make file and reconfigured and ran nmake again.
This time I started at 4:00 pm yesterday and right now it is 6:04 pm the following day and my computer is still compiling. I don’t not know why it is doing this. You mentioned that using nmake without the aid of jom, it would take at least 10 hours. I used jom and Well it is over 10 hours right now and this time I set N=4.
I did noticed I had a warning: C4189: ‘q’ local variable is inialized but not reference. And warning: C4189: ‘d’ local variable is inialized but not reference.
Right now, I am getting alot of warnings a great number of *.cpp files that used a header file yvals.h(21) that is included in visual studio 2010.
GCController.cpp
c:\Microsoft Visual Studio 10.0\VC\include\yvals.h(21) :warning C4005: ‘HAS-TRl’: macroredefinition
command_line arguments: see previous definition of ‘_HAS_TRl’
These were a few files that did not generate the code after compiling, but even with this warning, the majority of the .cpp files did generate the codes.
These warnings was included in the last 8 hours of compilation.
I am not sure what this means? I do not know if I downloaded the right QT and pearl. Should I have downloaded the 64 bit QT and pearl for my window 7, 64 bit system?
If I just used nmake without jom, can I still run jom.exe clean to delete the temp files?
I was wondering if someone can help me with these issues of the warnings, 32 bit or 64 bit software to download, and why it is taking so long to compile the build?
I see no problems with warnings you get – they are not critical.
As for the compilation time – Celeron is very weak, it might take looong time to build Qt using it. Also you don’t need jom – it is tuned especially for multi-core CPUs.
Dear Pavel,
I run into tons of this warnings too, however, at last the nmake step failed:
jom: C:\Qt\qt-everywhere-opensource-src-4.8.4\src\3rdparty\webkit\Source\WebCore\Makefile.WebKit [release] Error 2
jom: C:\Qt\qt-everywhere-opensource-src-4.8.4\src\3rdparty\webkit\Source\WebCore\Makefile.WebKit [sub-WebCore-make_default-ordered] Error 2
jom: C:\Qt\qt-everywhere-opensource-src-4.8.4\Makefile [sub-WebCore-make_default-ordered] Error 2
I installed a x86 perl and updated my msvc2010 with SP1. And I also tried x86 and x64 prompt of msvc2010.
I did update the user environment as your great suggestion.
Oh, there is something else I have to mention: I have compiled one Qt with your suggestions before with a x86 prompt of msvc2010. Then I need a x64 version, so I complied the static library with almost the same steps. But now it failed.
Could you please give me a hand on this ? Thank you so much!
(From China)
Thank you so much,it’s owesome!
Two questions now boring me:
1、My cpu is 2-cores,but I set the argument n=4,will it be OK? (It is “jomming” now)
2、It has running for 4 hours,How much time will it take ?(notebook &CPU: T6600(2cores,2.2GHz)&traditional harddisk(320GB))
>> 1
No problem, it will be ok.
>>2
No idea, but it will be much longer then numbers in my tutorial.
(From China)
Thank you so much!
It is perfect! And It is a wonderful day!
CPU:T6600(2cores&2.2GHz)
time:7hours(8:00-15:00)
file.size:6.14 GB
Thanks again!
“** 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.”
You can also change the drive by typing just d:. This works in all Windows versions (and DOS as well).
FYI—I just compiled Qt 4.8.2 x64 with SSL support in VS2010 (Win7x64) using these instructions and nmake instead of jom. Here’s my config (configure_SSL.cache… it can be loaded with “configure.exe -loadconfig SSL”):
-debug-and-release
-opensource
-shared
-platform
win32-msvc2010
-no-qt3support
-qt-libpng
-qt-libmng
-qt-libtiff
-qt-libjpeg
-mp
-openssl
-qt-zlib
-qt-sql-sqlite
-L c:\dev\lib\openssl-0.9.8k_X64\lib
-l libeay32
-l ssleay32
-I c:\dev\lib\openssl-0.9.8k_X64\include
Hi,
Can you give some more details on how to configure ssl support, using jom, VisualStudio2010, open SSL 1.0.1
Thanks
Just saw this. I haven’t found any binaries for 1.0.1 yet, but there’s some binaries for 0.9.8k for Windows at this link: http://code.google.com/p/openssl-for-windows/
Any one tried compiling with Visual Studio 2012 Professionel on windows 8?
[From China]
Not yet.
Is there a way to compile qt with vs2012 ultimate? I couldnt find any mkspecs for msvc2012.
A small remark: I had no problems to compile vs2010 with the qt 4.8.2-version on 64bit-systems (win7, vs2010 ultimate).
Thank you for this great tutorial 🙂
I came across this stackoverflow article on how to compile using MSVC2012. Although Qt doesn’t officially support 2012 yet, I thought others might find that link useful.
If you have a problem with 64-bit release build in VS2010, install KB2280741 first.
VS2010 have a bug with class/struct aligment with /02 linker option, if their size are bigger than 64 bit, which causes memory protection error.
Dear all,
Thank all of you for your so detailed information. By step by step instruction, I have successfully build Qt 4.8.3 64 bit libs under Windows 7 64bit + VS2010. The only thing we should notice is that during building, the following errors displayed:
platform\DefaultLocalizationStrategy.cpp(327) : error C2001: newline in constant
platform\DefaultLocalizationStrategy.cpp(327) : fatal error C1057: unexpected end of file in macro expansion
jom: C:\Qt\4.8.3\src\3rdparty\webkit\Source\WebCore\Makefile.WebKit.Debug [tmp\obj\debug_shared\DefaultLocalizationStrategy.obj] Error 2
jom: C:\Qt\4.8.3\src\3rdparty\webkit\Source\WebCore\Makefile.WebKit [debug-all] Error 2
jom: C:\Qt\4.8.3\src\3rdparty\webkit\Source\Makefile.WebKit [sub-WebCore-make_default-ordered] Error 2
After change the code in line 327
return WEB_UI_STRING(“Look Up “””, “Look Up context menu item with selected word”).replace(“”, truncatedStringForLookupMenuItem(selectedString));
to the following:
return WEB_UI_STRING(“Look Up \”\””, “Look Up context menu item with selected word”).replace(“”, truncatedStringForLookupMenuItem(selectedString));
all problems solved.
Thanks,
Zhanghong Tang
Why not contribute this article to http://qt-project.org/wiki/ ?
Today I managed to build for VS2012 using these instructions. Just changed the specs to vs2012 instead of vs2010.
To any others trying to do so: be careful for this:
https://bugreports.qt-project.org/browse/QTBUG-27395?focusedCommentId=185116#comment-185116
I use qt creator 2.5.0 based on qt 4.8.1 (32bit) and qt-everywhere-opensource-src-4.8.2
i wrote my app in qt and link it with vs2005 and debug with 32bit configuration
now ,i have to debug with 64bit config.
what i do ?
please help me,i am an elementary level of qt programming
thanks .
Successfully compiled for 4.8.3 on x64 today. Works fine with Visual Studio Addin, some issues with RCC_DIR , needed to set it to ./GeneratedFiles in my .pro files to pick up the moc results.
Just built 4.8.3 with VS2010 on a 64-bit Intel 2nd-gen i5, so your instructions still hold good! Many thanks indeed.
Further to my remark above, that was under Windows 7. Interestingly the process fails under Windows 8 at the Jom stage with a message along the lines of “Qt detected Windows 6.2. Untested version”. This is clearly a Qt issue – will flag it with them but wanted to save anyone else chewing their time until it’s resolved!
Thank you Mike, whatnick, Borislav Stanimirov and all other guys who reported their results with newer versions of Qt & VC & Windows.
I’m adding your reports to the post. I am sure other visitors (as well as me) will benefit from your comments.
Quick addendum – I copied the whole tree for 4.8.3 from a Windows 7 64-bit Intel i5 build onto a Windows 8 64-bit Intel i7 machine, and intially Qt Creator didn’t like the “version” I was trying to add, giving it the all-too-familiar red blob treatment. However, setting the QTDIR and QMAKESPEC environment variables and then re-running the configure step seemed to resolve the situation and Creator on Windows 8 now happily recognises my 4.8.3 “version” and associates a proper tool chain with it. Hope it helps someone else!
QT is succesfully compiled in my Windows 7 x64 box with Windows SDK 7.1 using x64 environment. The QT demo window execute fine, but if i run any demo that require Phonon, the app is crash before the main window show up. The crash report says the conflicting module is phonon_ds94.dll.
Anyone have the same problem?
Thx in advance.
Many thanks for this guide, I’ve just built 4.8.4-x64 successfully with VS2010 on my Intel 3nd-gen i7. I only used the option “-release” instead of “-debug-and-release” and the compilation took less than 40 minutes. I just had some issues when installing the DirectX SDK (required for Phonon support), but I found a quick solution at the following link, as I reported in another comment above, http://stackoverflow.com/questions/4102259/directx-sdk-june-2010-installation-problems-error-code-s1023
Thank you for the useful information!
Update:
Today I managed to get a “complete static build” of Qt 4.8.4 for x64
with both VS2010 and the Intel compiler (Intel Composer XE 2013).
By “complete” I mean that not only Qt was built statically itself,
but now it’s also independent from the msvc*.dll runtime libraries.
I’ll just show what I did for the Intel compiler build:
in “qmake.conf” located in C:\Qt\4.8.4\mkspecs\win32-icc
I changed the line:
QMAKE_CFLAGS_RELEASE = /O2 /MD /GF /GS-
to
QMAKE_CFLAGS_RELEASE = /O2 /MT /GF /GS-
then I just replaced:
Step 5 with:
QTDIR=C:\Qt\4.8.4
QMAKESPEC=win32-icc
Step 9 with:
Start > Intel Parallel Studio XE 2013 > Command Prompt >
Parallel Studio XE with Intel Compiler XE v13.0 Update 1 >
Intel 64 Visual Studio 2010 mode
Step 10 with:
cd c:\Qt\4.8.4
configure -static -release -opensource -platform win32-icc
..\jom\jom.exe -j N
(and the other steps accordingly for the 4.8.4 version, of course).
With the Intel-i7-3770k and N=8 it took about 1 hour, but the Qt folder
*after* cleaning with “jom clean” has the huge size of nearly 9Gb.
I expected the folder to be very large, given the static build of libraries
and demos/examples, but I didn’t expect that large! 🙂
PS: I had already installed Windows SDK 7.1, DirectX SDK June 2010
and ActivePerl 5.16 for x64.
Thank you, Vincenzo one more time!
I am sure your notes will be very useful for many people (including me, since I am planning to switch to Intel compilers :)).
By any chance, do you have any desire & time to check Qt 5.0 compilation released today :)?
Done! The Qt 5.0.0 libraries for x64 were compiled successfully with VS2010!
Here are the steps I’ve done (on Windows 7 Ultimate SP1 64bit): first of all,
I must say that I had already installed VS2010 and Windows SDK 7.1 in the following order:
Visual Studio 2010
Windows SDK 7.1
Visual Studio 2010 SP1
Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
[this is required for building Qt5, here’s the link:
http://www.microsoft.com/en-us/download/details.aspx?id=4422%5D
After that, I installed:
-ActivePerl 5.16.1.1601 for x64
-Python 2.7.3 (for x64) through the installer at python.org
-ICU Libraries v50.1.1 for win64-msvc10
[these libraries provide Unicode and Globalization support and they
are required for building QtWebKit, you can download them here:
http://site.icu-project.org/download/50#TOC-ICU4C-Download%5D
I extracted the content of the folder “qt-everywhere-opensource-src-5.0.0”
[in qt-everywhere-opensource-src-5.0.0.tar.gz] to C:\Qt\5.0.0\
and made sure that the environment variables were properly set:
QTDIR=C:\Qt\5.0.0\qtbase
QMAKESPEC=win32-msvc2010
and added
%QTDIR%\bin;
C:\Qt\5.0.0\gnuwin32\bin;
C:\icu\bin64;
C:\Python27\DLLs;
C:\Python27
to PATH (“C:\Perl64\site\bin” and “C:\Perl64\bin” were already added
by the ActivePerl installation; however, make sure that they are properly set)
After making these changes I recommend to log off and re-log in,
this step shouldn’t be necessary in order to update the env variables,
but after many failures that’s what I did and it worked 😛
Now, that’s the point where I lost much time. I couldn’t run the “configure.bat”
script in C:\Qt\5.0.0\, it just exited with an error message: configure.exe
is not a recognized command.. or something similar.. so, that’s my work around:
go into C:\Qt\5.0.0\qtbase, here you will find another “configure.bat”,
just open it with a text editor and comment out the 4th line:
if not exist %QTSRC%\.gitignore goto sconf
i.e. change it to:
::if not exist %QTSRC%\.gitignore goto sconf
at this point you can start the “Visual Studio x64 Win64 Command Prompt (2010)”
command prompt (in Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools)
and then:
cd C:\Qt\5.0.0
configure -prefix %CD%\qtbase -release -opensource -icu -platform win32-msvc2010
C:\Qt\jom\jom.exe -jN
the “%CD%” placeholder stands for “current directory”, so you will find
your build in the subdirectory “qtbase”. This worked for both the x64
and x86 builds with *VS2010* (I used Python and Perl 32bit for the latter).
It DID NOT work for the Intel Compiler, the compilation process failed
after a few minutes. I’m working on it, though.. 🙂
Well, that was very fast. Thank you!
I’ve updated the page with links to your comment.
As far as I see, this is the first instructions to build Qt 5.0.0 for x64 around the Web….
You’re very welcome Pavel. Thank you for mentioning me.
I hope everyone will find these instructions as useful
as I found yours on Qt 4.x, your guide helped me a lot.
Let’s wait and see if someone will send us their feedback,
it’s likely that some step is unnecessary or simply can be
improved. What I’m sure of is that it worked on my system.
I’ll let you know about any correction or improvement on
using the Intel Compiler. Enjoy!
where do you put the ICU Libraries?
Take a look silly it’s in the post 🙂 ! He extracted it in C:/ and added it to the path.
Correction:
sorry, the instructions I posted were valid only for Qt 5.0.0 without
QtWebKit support. Qt 5 will compile without the “-icu” option, following
the previous guide. However, in order to build Qt 5 with QtWebKit, you
need to make just two other steps, before running “configure.bat”.
First, install Ruby, and update the PATH variable adding “C:\Ruby192\bin”
(if you installed Ruby v1.9.2). You will also need to open the file
“qmake.conf” in C:\Qt\5.0.0\qtbase\mkspecs\win32-msvc2010 and replace:
line #20:
QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t
with
QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t /I”C:\icu\include”
line #64
QMAKE_LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT
with
QMAKE_LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT /LIBPATH:”C:\icu\lib64″
line #75
QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib
with
QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib icudt.lib icuin.lib icuio.lib icule.lib iculx.lib icutu.lib icuuc.lib testplug.lib
After these changes you will be able to build Qt 5 with the “-icu” option enabled.
That’s all.
Hi Vincenzo Mercuri,
i followed your tutorial and have a problem, maybe u can help me.
when i start nmake after 3 minutes it stops and say:
NMAKE : fatal error U1077: ‘”c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.EXE”‘ : return code ‘0x2’
i used:
Visual Studio 2010
Windows SDK 7.1
Visual Studio 2010 SP1
Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
-ActivePerl 5.16.1.1601 for x64
-Python 2.7.3 (for x64) through the installer at python.org
-ICU Libraries v50.1.1 for win64-msvc10
Thanks
Instead of editing the qmake.conf adding the following flags to configure worked for me:
-I ”C:\icu\include” -L ”C:\icu\lib64″ -l icudt -l icuin -l icuio -l icule -l iculx -l icutu -l icuuc -l testplug
where did you add it to exactly?
thanks!
I am trying to compile qt5 with VC 2010 Express (Windows 7 64bit) and get an error in compiling.
I installed
Visual Studio 2010 Express
Windows SDK 7.1
Visual Studio 2010 SP1
Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
Then called configure in Visual Studio Command Prompt (2010)
“configure -static -developer-build -mp -opengl desktop -platform win32-msvc2010 -nomake examples -nomake demos”
and stated compiling with nmake, after some time I get the error:
Microsoft (R) Program Maintenance Utility Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
echo 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ “debug\\composition.exe.embed.manifest”>debug\composition.exe_manifest.rc
if not exist debug\composition.exe del debug\composition.exe.embed.manifest>NUL 2>&1
if exist debug\composition.exe.embed.manifest copy /Y debug\composition.exe.embed.manifest debug\composition.exe
_manifest.bak
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS “/MANIFESTDEPENDENCY:type=’win32′ name=’Microsoft.
Windows.Common-Controls’ version=’6.0.0.0′ publicKeyToken=’6595b64144ccf1df’ language=’*’ processorArchitecture=’*'” /MA
NIFEST /MANIFESTFILE:debug\composition.exe.embed.manifest /OUT:debug\composition.exe @C:\Users\adrian\AppData\Local\Temp
\nm9B38.tmp
Qt5Guid.lib(qopenglframebufferobject.obj) : error LNK2005: “class QImage __cdecl qt_gl_read_framebuffer(class QSize cons
t &,bool,bool)” (?qt_gl_read_framebuffer@@YA?AVQImage@@ABVQSize@@_N1@Z) already defined in Qt5OpenGLd.lib(qgl.obj)
Creating library debug\composition.lib and object debug\composition.exp
debug\composition.exe : fatal error LNK1169: one or more multiply defined symbols found
NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.EXE”‘ : return code ‘0x491’ Stop.
Any idea how I can solve this?
thanks
I just compiled Qt 4.8.4 x64 bit.
23 minutes with jom -j 8.
shiny new i7 notebook with 7200rpm drive on windows 8.
running RetroUI for my Start Button
I uninstalled all compilers (after 2 days of problems).
already installed (64 bit versions where possible):
Perl 5.15.1
Python 2.7.3
Cmake 2.8.10
OpenCV 2.4.9
TBB 4.1
Eigen
CUDA 5.0
Point Cloud Library 1.6
OpenNI 2.0
Dot NET 4.0
VS2008 SP1
Path Editor
Tortise GIT
and
QT 4.8.4
Then followed the recipie exactly:
VC2010 Express
Win SDK 7.1 (UN check c++ compilers)
VC2010 SP1 “VS10sp1-KB983509”
–restart–
VC2010 compiler update “VC-Compiler-KB2519277”
Parafly,
The trick is for VS2010 Express Edition to run the 64 bit command prompt. But there isn’t one, per se.
So you have to make one:
copy the VS2010 command prompt
Its the same command from Windows\system32\cmd.exe, but it needs parameters:
go to properties and edit the target:
%comspec% /k “”C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat”” amd64
you might want to set run as administrator (I had to copy to my docs then back in).
Start the Prompt.
Verify that it is 64bit by opening Task Manager>Details (select Platform display column)
you should see cmd.exe as 64 bit
at the VS cmd Prompt change to \bin
Then run SetEnv.cmd /Release /x64
now cd.. up to C:\ and over to your Qt folder
I ran:
configure.exe -release -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no-qt3support -no-multimedia -no-ltcg -opensource
about 10 minutes later…done.
Then I had to run
..jom.exe -j 8
I couldn’t get it to run from the \jom folder so I copied jom.exe to \Qt
23 minutes later….ding.
watching resource monitor, all 8 cpu’s were at 100%, yikes.
I hope this Helps.
Greg
Hi Greg
Thanks for your answer. I can compile Qt4.8.4 but have problems with compiling qt5.0.0.
hi, parafly.
I have a same problem with you. Have you solve it?
It is a bug that is supposed to be fixed already: http://qt.gitorious.org/qt/qtbase/commit/c927d6b9e161ee22822dbfb0654f5734c9101aa7/diffs
However, this fix is currently not in the 5.0.1 source code version downloadable from the website, but only on git.
Hi Vincenzo ,
I followed all your directions. I installed the latest of the programs, but I’m getting this error: zdll.lib is missing. Could you please take a look and suggest where I can get it and where I should install it?
Many thanks.
C:\Qt\5.0.0>jom -j 4
jom 1.0.13 – empower your cores
cd qtbase\ && ( if not exist Makefile C:\Qt\5.0.0\qtbase\bin\qmake C:\Qt
\5.0.0\qtbase\qtbase.pro -o Makefile ) && C:\Qt\5.0.0\jom.exe -f Makefile
cd src\ && ( if not exist Makefile C:\Qt\5.0.0\qtbase\bin\qmake C:\Qt\5.
0.0\qtbase\src\src.pro -o Makefile ) && C:\Qt\5.0.0\jom.exe -f Makefile
cd tools\ && ( if not exist Makefile C:\Qt\5.0.0\qtbase\bin\qmake C:\Qt\
5.0.0\qtbase\src\tools\tools.pro -o Makefile ) && C:\Qt\5.0.0\jom.exe -f Makefil
e
cd bootstrap\ && ( if not exist Makefile C:\Qt\5.0.0\qtbase\bin\qmake C:
\Qt\5.0.0\qtbase\src\tools\bootstrap\bootstrap.pro -o Makefile ) && C:\Qt\5.0.0\
jom.exe -f Makefile
C:\Qt\5.0.0\jom.exe -f Makefile.Release
cd moc\ && ( if not exist Makefile C:\Qt\5.0.0\qtbase\bin\qmake C:\Qt\5.
0.0\qtbase\src\tools\moc\moc.pro -o Makefile ) && C:\Qt\5.0.0\jom.exe -f Makefil
e
C:\Qt\5.0.0\jom.exe -f Makefile.Release
link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE ”
/MANIFESTDEPENDENCY:type=’win32′ name=’Microsoft.Windows.Common-Controls’ versio
n=’6.0.0.0′ publicKeyToken=’6595b64144ccf1df’ language=’*’ processorArchitecture
=’*'” /MANIFEST /MANIFESTFILE:..\..\..\bin\moc.exe.embed.manifest /OUT:..\..\..\
bin\moc.exe @C:\Users\Farid\AppData\Local\Temp\moc.exe.4520.16.jom
LINK : fatal error LNK1181: cannot open input file ‘zdll.lib’
jom: C:\Qt\5.0.0\qtbase\src\tools\moc\Makefile.Release [..\..\..\bin\moc.exe] Er
ror 1181
jom: C:\Qt\5.0.0\qtbase\src\tools\moc\Makefile [release] Error 2
jom: C:\Qt\5.0.0\qtbase\src\tools\Makefile [sub-moc-make_first] Error 2
jom: C:\Qt\5.0.0\qtbase\src\Makefile [sub-tools-make_first] Error 2
jom: C:\Qt\5.0.0\qtbase\Makefile [sub-src-make_first] Error 2
jom: C:\Qt\5.0.0\Makefile [module-qtbase-make_first] Error 2
C:\Qt\5.0.0>
Dracula123,
I’m using Qt 4.8.4, but you should have the zlib source and headers in something similar to C:\qt\4.8.4\src\3rdparty\zlib
make sure you check the BUILD-BUILD_ZLIB checkbox in CMake.
Parafly and Dracula123,
I had problems with building Qt 5.0, I’ll try it again later and post the results.
Greg
Thank you for your reply Greg.
I’m a little confused. In your instructions you mention you installed (or uninstalled CMake), but you don’t mention how it is used. Do you mean I should install CMake and compile the zlib library myself?
Alternatively, I tried adding the option:
-qt-zlib
in Qt’s configure command. It got rid off the zdll.lib error, but now I have a similar error with png library saying that it is missing. I tried adding the option:
-qt-libpng
But this time, this Qt configure option did not solve the problem.
One more question, Greg. Are you using CMake to compile/build Qt 4.8.4?
Thank you.
Hi, I believe that something must be messed up with your Qt source directory, try re-installing the source tree and run configure.exe again, there’s no other step to follow for building Qt 4.8.4. I compiled it successfully many times for different configurations and platforms and did not find the issues you mentioned above. I did everything on command line, never used CMake.
Oops sorry, that was Qt 5 you were talking about : ) make sure you followed each step I posted. I deleted and installed a clean source directory many times before getting a successful build. However, I never found the “zdll.lib” issue. Did you install Ruby?
Hi,
My goal is to compile a VS2012 project (including Qt-libraries) to a target machine type x64.
So I followed the steps above and compiled Qt5 on Win 7 (x64) with VS2012 (x64 command prompt).
Everything seemed to be configured and compiled without errors.
I then use the x64 compiled Qt libraries in order to create a simple Qt_app project and specify the target machine x64 in VS2012 project settings.
When compiling I get the error message:
error LNK1112: module machine type ‘x86’ conflicts with target with machine type ‘x64’. File: moc_qt_app_src.obj (with the files: qt_app_src.h, qt_app_src.cpp, qt_app_src.ui, qt_app_src.qrc)
Did some modules compile to a x86 target and some to a x64 target? and how to compile all modules to a x64 target?
Hi clabbfand. Did you solve this problem? I have the same issue.
Please tell me if you found the solution
Hello Vincenzo Mercuri, I am trying to install the lastest Qt5 on VS2010 32 bits,
I am almost there, but the FTP server to download the lastest jom is down. Do you know a place to download this file?
Thank you so much. I will try to post my process later.
Have a wonderful day.
Best,
Eddy
Hi,
I have tried the above with the following:
Qt 4.8.4, VisualStudio2010, OpenSSL v1.0.1,
I needed to build Qt since I can not access https sites. so I have tried to build with openssl.
I followed the above steps and changed the configuration a bit to add the open ssl:
configure.exe -platform win32-msvc2010 -opensource -shared -debug-and-release -openssl-linked -I C:\OpenSSL-Win32_full\include\openssl -L C:\OpenSSL-Win32_full\lib
I have installed open ssl under C:\OpenSSL-Win32_full
After build of Qt was done, I have tried to build and run the previewer example from the Qt installation dir.
There i have tried to load http url and it worked fine, when I tried to load https url nothing happened. the page was blank.
I tried to see if ssl is supported by adding :
bool isSSL = QSslSocket::supportsSsl();
I get isSSL = true.
Does anyone have an idea why https does not work.
Working with Qt 5.0.1 and compiling for VS2010 in 64bits.
I spent about 3 days trying to compile, even after reading these instructions, and finally managed to get it running, so I’d like to share my tips:
1) Anti-viruses are definitely problematic, as well as anything that may interfere with the files: that means also backup tools, dropbox/googledrive etc… I strongly recommend stopping all these services/tools.
2) To be sure to avoid any conflict, I ran the Visual Studio Command Prompt in administrator mode! (x64 for x64 compilation)
3) Note that if you installed QT5 x86 with the installer, you have Qt Creator (32bits), but no need to recompile Qt Creator for 64bits: QtCreator will work with both x86 and 64bits.
4) to compile QtWebKit, you also need Ruby. That was missing in the steps.
5) Here QTDIR is defined as the target installation path: this is basically used for the -prefix option in configure, so use either one or the other, but -prefix will override the QTDIR variable.
6) Between steps 11 and 12, you need to run
nmake install
7) To build the docs, run
nmake docs
after install8)I strongly recommend using
-debug-and-release
or you will have troubles debugging in VS20109)For some reason the first time I compiled using jom, VS complained qmake was made with an unrecognized make tool. I may have screwed up as I had installed the VS add-in 1.1.0 instead of 1.2 and maybe that was the reason, but because of this error I used nmake and it worked fine.
10) I still have issues compiling with OpenSLL. to be continued…
11) If nmake fails and you need to reconfigure,
nmake -confclean
doesn’t work.nmake clean
works but does not clean the Makefiles so my best recommendation to start off from a clean state is to delete all and copy the source over. Using Git may be better and easier but I haven’t found Qt5.0.1 on Git; the links all point to 4.8 plus I don’t want to run from dev sources, so I used to .zip sources.12) my batch files commented:
Setting PATHs first (in a separate .BAT file because you may have to run configure and nmake many times, but you don’t want to set the PATH many times or it will just add the same path multiple times.
SETPATHS.BAT
set ICU=D:\Qt\5.0.1\icu4c-49_1_2-Win64-msvc10\icu REM ICU directory. I used 4.9.1.2 because I heard 5.0.1 had issues
set CL=/MP REM to activate multi-processor use with nmake
PATH=%PATH%;D:\Qt\5.0.1\src\qtbase\bin;%ICU%\bin64;
BUILD.BAT
set PREFIX=D:\Qt\5.0.1\msvc2010-x64 REM my target install path
configure -prefix %PREFIX% -platform win32-msvc2010 -debug-and-release -opensource -opengl desktop -confirm-license -nomake examples -nomake demos -nomake tests -icu -I %ICU%\include -L %ICU%\lib64
then you want to run
nmake
when done (after a good 45min or so on my quadcore)… run
nmake install
to copy the files to the destination directory specified by PREFIX
to solve any issue in compiling Qt programs within VS2010, I added
D:\Qt\5.0.1\msvc2010-x64\includes
to the project environment, but it could also be put straight into the PATH too.Hope this helps.
by the way… your posts obviously helped getting started, so thanks a lot for that! I just wish it’d be a little simpler to get setup; too many details and possibilities to go wrong!
P:lease help me somenody i’ve problem while executing my project in visual c++ :
rply fast—-
INK : fatal error LNK1104: cannot open file “Debug/chetan.exe”
Error executing link.exe.
another point:
to build qtwebkit, you need to have the tools in gnuwin32\bin in your path
I’m about to get going on this. Can anyone answer why the Qt folks made it *so* hard to simply build and install? Why couldn’t they spend a month or so getting this refined down to a simple process? The fact that one has to search through lengthy message board threads just to get their product to run shows a lack of commitment on their part. Thanks for all the help here though.
I understand your frustration and felt the same way for a while. Ultimately, though, it really is pretty straightforward. They made it this complicated because Qt has linking points for several other libraries (WebKit, OpenSSL, JPEG, to name a few) that they don’t actually own and can’t distribute directly.
Giving the user (you and me) the option to make Qt as big, as small, as simple, as complicated as we want it to be really is pretty ingenious. That said, it is pretty mind-boggling that they don’t distribute a 64bit version.
i need to build it on win64 and msvc2010
I made it step by step but i take error when configure -debug-and-release -opensource -platform win32-msvc2010
copy qmake.exe C:\Qt\4.7.1\bin\qmake.exe
1 file(s) copied.
Creating makefiles in src…
Generating Visual Studio project files…
Could not find mkspecs for your QMAKESPEC(win64-msvc2010) after trying:
C:\Qt\4.7.1\mkspecs
Error processing project file: C:\Qt\4.7.1/project
s.pro
Qmake failed, return code 3
Generating Makefiles…
Could not find mkspecs for your QMAKESPEC(win64-msvc2010) after trying:
C:\Qt\4.7.1\mkspecs
Error processing project file: C:\Qt\4.7.1/project
s.pro
Qmake failed, return code 3
Configuration: Win7(64), MSVS 2012, QT5.0.2
Trouble: a some problems with linking.
Generating Code...
Compiling...
moc_qwt_analog_clock.cpp
moc_qwt_compass.cpp
moc_qwt_counter.cpp
moc_qwt_dial.cpp
moc_qwt_knob.cpp
moc_qwt_slider.cpp
moc_qwt_thermo.cpp
moc_qwt_wheel.cpp
Generating Code...
linking ..\lib\qwt.dll
Qt5OpenGL.lib(Qt5OpenGL.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
NMAKE : fatal error U1077: 'echo' : return code '0x458'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
Hi,
MOC keeps crashing in my PC i am using window 7 x64 and temp files also gets corrupt while compiling Qt4.8.2 with visual studio 2010.
Please help.
Hi,
This manual works great with version 4.7.3. I tried the same with 5.1.0 a couple of days back, and i could not build successfully. Long overdue for a new manual for 5.1.0+. Nice effort that you are doing. Thanks.
Once you are done with the step where you configure, you can see Projects.sln file in the %QTDIR%. You can open this with visual studio and use a build accelerator, if you have one. For example , i used the incredibuild accelerator that does distributed build and got it done in 45 mins.
I also had trouble when using Visual Studio when building the solution file. Apparently, Visual Studio has to be run in the administrator mode for server registration to go through (registering dll’s).
The Error was this:
>>C:\Qt\4.7.3\bin\idc.exe C:\Qt\4.7.3\examples\activeqt\wrapper\release\wrapperax.dll /regserver
Failed to register server!
As an update, I’ve also compiled version 4.8.4 and 4.8.5 in 32bit and 64bit using MSVC2010. Haven’t played with VS2012 yet, but that’s coming.
I’ve also compiled both 4.8.4 and 4.8.5 with OpenSSL 0.9.8k to add SSL capabilities for interacting with Google’s APIs (it works!). It requires a bunch of extra settings in configure.exe, but it’s not too bad. I’d like to try out OpenSSL 1.0.1, but I can’t find windows7-compatible 64bit binaries and I’m not interested enough to try to compiling OpenSSL myself yet.
Hi Evon,
thanks for the straight forward tutorial. As some others here already mentioned, your tutorial delivers all the informations which other tutorials don’t. That saved me a lot of hours. I would suggest, that the official QT tutorial for static linking, should be updated with at least a link to your tutorial.
I wasted more than 20 hours, to find only your tutorial was working.
I’ve successfully build it on Windows 7 (64-Bit) but compiled it for 32-Bit target.
Forget to mention, that I used the VS2012 Express Edition. No problem with it so far.
I mean, thanks Pavel 😉
Thanks to you too for giving the feedback.
I’ve successfully build QT 5.1.0 (32Bit) with the help of this tutorial. The only thing which now must be distributed together with the application(.exe) is the MSVC Redistibutable Package (in my case for MSVC2012). After that I’m able to run my application on any Windows machine.
Thanks Pavel. This guide is really helpful. I’ve successfully compiled qt4.8.5 (win32-msvc2010) on 64bit windows 7.
But I still have a problem. When I run the official “animation” example in the Qt Creator 2.3.1, 14 C1083 error were detected.
The not found files were QPointF, Qt, QGraphicObject, etc.
Two things worth mentioning:
1. I can build my own “hello, world” application using Qt Creator;
2. The “animation” example runs well in VS 2010 with Visual Studio Add-in built.
Hello,
Just wonder how I can create a x64 project by default without going thru
changing platforms and attaching QT to the project in QT settings (selecting version of QT)
Just want to start using a x64 project straight away when I create it in the wizard.
Thanks
Jack
I tried compiling QT 5.2.0 with VS 2010 x64.
I run configure with -debug-and-release flag,
after it finished, and after running jom, I cannot find the xxxd.dll (all the debug DLLs) so I cannot debug my applications with this library.
(with release everything is working as expected.)
any idea how can I get those debug DLLs?
thanks!
I’m getting this error when trying to compile QT 5.2.1 with VS 2013
In file included from ..\..\include/QtGui/qopengl.h:1:0,
from ..\..\include\QtGui\5.2.1\QtGui/qpa/../../../../../src/gui
/kernel/qplatformopenglcontext.h:60,
from ..\..\include\QtGui\5.2.1\QtGui/qpa/qplatformopenglcontext
.h:1,
from ..\..\include\QtGui\5.2.1\QtGui/qpa/../../../../../src/gui
/kernel/qplatformwindow.h:59,
from ..\..\include\QtGui\5.2.1\QtGui/qpa/qplatformwindow.h:1,
from kernel\qwindowsysteminterface.cpp:42:
..\..\include/QtGui/../../src/gui/opengl/qopengl.h:82:25: fatal error: GLES2/gl2
.h: No such file or directory
compilation terminated.
jom: C:\Qt\Qt5.2.1\5.2.1\Src\qtbase\src\gui\Makefile.Debug [.obj\debug\qwindowsy
steminterface.o] Error 1
g++ -c -include .pch\debug\qt_gui_pch.h -pipe -fno-keep-inline-dllexport
-g -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_USING_NAME
SPACE -DQT_BUILD_GUI_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_
WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_D
ISABLE_DEPRECATED_BEFORE=0x040800 -D_USE_MATH_DEFINES -DQT_USE_BUNDLED_LIBPNG -D
QT_NO_EXCEPTIONS -DQT_CORE_LIB -I. -I”..\..\include” -I”..\..\include\QtGui” -I”
..\..\include\QtGui\5.2.1″ -I”..\..\include\QtGui\5.2.1\QtGui” -I”tmp” -I”image”
-I”..\3rdparty\libpng” -I”..\3rdparty\libjpeg” -I”..\..\include\QtCore\5.2.1″ –
I”..\..\include\QtCore\5.2.1\QtCore” -I”..\..\include\QtCore” -I”.moc\debug” -I”
..\..\mkspecs\win32-g++” -o .obj\debug\qplatforminputcontextfactory.o kernel\qpl
atforminputcontextfactory.cpp
jom: C:\Qt\Qt5.2.1\5.2.1\Src\qtbase\src\gui\Makefile [debug-all] Error 2
jom: C:\Qt\Qt5.2.1\5.2.1\Src\qtbase\src\Makefile [sub-gui-make_first] Error 2
jom: C:\Qt\Qt5.2.1\5.2.1\Src\qtbase\Makefile [sub-src-make_first] Error 2
C:\Qt\Qt5.2.1\5.2.1\Src\qtbase>
Thanks Pavel and Vincenzo for your guide!
However, the following error kept appearing, and I have no idea why it fails.
I am building Qt 5.0.0 from source for msvc2010-64 bit. And I have been building it for days.
My configuration is:
Active Perl 520
ICU 4c-49_1_2-win64msvc2010
Python278
jom
(with all path set)
With command:
configure -debug-and-release -opensource -icu -opengl desktop
error:
tools\qcollator.cpp(47) : fatal error C1083: Cannot open include file: ‘unicode/
utypes.h’: No such file or directory
tools\qstring.cpp(3841) : warning C4309: ‘argument’ : truncation of constant value
tools\qstring.cpp(3842) : warning C4309: ‘argument’ : truncation of constant value
qstringbuilder.cpp
Generating Code…
jom: G:\Qt\qt-everywhere-opensource-src-5.0.0\qtbase\src\corelib\Makefile [debug-all] Error 2
jom: G:\Qt\qt-everywhere-opensource-src-5.0.0\qtbase\src\Makefile [sub-corelib-make_first] Error 2
jom: G:\Qt\qt-everywhere-opensource-src-5.0.0\qtbase\Makefile [sub-src-make_first] Error 2
jom: G:\Qt\qt-everywhere-opensource-src-5.0.0\Makefile [module-qtbase-make_first] Error 2
I wonder why utypes.h file cannot be located, and does it directly lead to build fail?!
Thanks much for any help!!
Ryan
Ryan, you need to add your icu directories and libraries to your configuration. The way I did it is to create a script to set the paths and environment variables. Here is mine which I named qt541vars.cmd:
@echo off
CALL “C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat” amd64
SET INCLUDE=%INCLUDE%D:\icu\include;
SET LIB=%LIB%D:\icu\lib64;
SET _ROOT=D:\qt5\5.4.1
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;D:\icu\bin64;D:\Python34\DLLs;D:\Python34;D:\Ruby22-x64\bin;%PATH%
SET QMAKESPEC=win32-msvc2010
SET QTDIR=%_ROOT%\qtbase
SET _ROOT=
Then I created a new shortcut on my desktop and used the following:
Target:
%SystemRoot%\system32\cmd.exe /E:ON /V:ON /k d:\qt5\qt541vars.cmd
Start in:
D:\qt5\5.4.1
You will need to adjust the paths for your system, of course. Then for configure I used:
configure -debug-and-release -opensource -icu -opengl desktop -confirm-license -l icudt -l icuin -l icuio -l icule -l iculx -l icutu -l icuuc -l testplug
Make sure you start with a fresh source tree before configuring. You can try
nmake distclean
before configuring, but I like to delete the tree and extract it again from the archive.I hope this helps.
Paul
Yeh, I can build it now. This “-l icudt -l icuin -l icuio -l icule -l iculx -l icutu -l icuuc -l testplug ” works for me!
Thanks Paul!
Ryan
Hi
I’m trying to build QT4.7.3 in order to get the required libraries for build VBox5.0 on win7 x86. After I built qt, I could see QtCore4.lib and QtNetwork4.lib under QT’s lib folder. But building VBox also requires other libraries including VBoxQtCore4.lib, QtCoreVBox4.lib, VBoxQtNetwork4.lib, QtNetworkVBox4.lib, which can’t be found from building QT. Do you know how to build those missing libraries? Do I need to build any additional component to get those?
The commands I used to build QT are:
configure -debug-and-release -opensource -no-webkit -platform win32-msvc2010
..\jom\jom.exe -j 4
Many thanks.
I’m trying to build QT4.8.6 with VS2013 in x64 mode on Win7 Pro.
I know that I need to run all the commands from the x64 command prompt as admin, but I am still getting a compile error. I used Jom and nmake, and in both cases the compilation fails.
I downloaded qt-everywhere-opensource-src-4.8.6.zip
Installed Perl
Made paths to the QT folder on C:\QT\4.8.6
To build I do “configure -mp -platform win32-msvc2013
then I do “nmake”
It starts to build but after a while (about 30min) I get:
…
…
moc_trackerclient.cpp
cl -c -nologo -Zm200 -Zc:wchar_t- -FS -Zi -MDd -MP -GR -EHsc -W3 -w34100
-w34189 -DUNICODE -DWIN32 -DQT_DLL -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB
-DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT
_THREAD_SUPPORT -I”..\..\..\include\QtCore” -I”..\..\..\include\QtNetwork” -I”..
\..\..\include\QtGui” -I”..\..\..\include” -I”..\..\..\include\ActiveQt” -I”tmp\
moc\debug_shared” -I”.” -I”..\..\..\mkspecs\win32-msvc2013″ -Fotmp\obj\debug_sha
red\ @C:\Users\ms-admin\AppData\Local\Temp\nm6CAC.tmp
qrc_icons.cpp
link /LIBPATH:”c:\Qt\4.8.6\lib” /LIBPATH:”c:\Qt\4.8.6\lib” /NOLOGO /DYNA
MICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS “/MANIFESTDEPENDENCY:type=’win32′ na
me=’Microsoft.Windows.Common-Controls’ version=’6.0.0.0′ publicKeyToken=’6595b64
144ccf1df’ language=’*’ processorArchitecture=’*'” /OUT:debug\torrent.exe @C:\Us
ers\ms-admin\AppData\Local\Temp\nm6DD5.tmp
LINK : fatal error LNK1104: cannot open file ‘debug\torrent.exe’
NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio 12.0
\VC\BIN\amd64\link.EXE”‘ : return code ‘0x450’
Stop.
NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio 12.0
\VC\BIN\amd64\nmake.exe”‘ : return code ‘0x2’
Stop.
NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
Stop.
NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
Stop.
NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
Stop.
Anyone have any idea on what could be wrong?
hello , i have this error set long time now , and i get desperate , just need some help
I am trying to build Qt 5.5 and use , MSVS 2013 on win 7
jom: C:\Qt\5.5\qt-everywhere-opensource-src-5.5.0\qtdeclarative\src\qml\Makefile.Debug [.generated\debug\RegExpJitTables.h] Error 1
jom: C:\Qt\5.5\qt-everywhere-opensource-src-5.5.0\qtdeclarative\src\qml\Makefile [debug-all] Error 2
jom: C:\Qt\5.5\qt-everywhere-opensource-src-5.5.0\qtdeclarative\src\Makefile [sub-qml-make_first-ordered] Error 2
jom: C:\Qt\5.5\qt-everywhere-opensource-src-5.5.0\qtdeclarative\Makefile [sub-src-make_first] Error 2
jom: C:\Qt\5.5\qt-everywhere-opensource-src-5.5.0\Makefile [module-qtdeclarative-make_first] Error 2
Does anyone know of a way to compile 4.7 with Visual Studio 2013 (msvc2012)? Can’t seem to get it to work.
Thanks a lot.. Worked fine with Qt 5.5
configure -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop -nomake examples -nomake tests
Does this work for Visual Studio 2013? 64-bit? In the same sort of way?
I am trying the obvious, -platform win64-msvc2013 and having problems with the platform.
I do not necessarily need/want to dive into VS2010 if I can avoid doing so.
Suggestions?
I should also mention, I am trying to build a Qt4 version, specifically 4.7.4.
Well, there was no MSVC2013 around in times of 4.7.4. and thus no configuration for 2013 exists.
I think the best you can do is to try to change the msvc2010 configuration file to make it work for 2013.
Or just compile the whole thing using MSVC2010 – probably would be faster with guaranteed result, even if you have to install in from scratch :(.
Thanks for the prompt reply. Of course, I get that, re: circa timing is concerned. I was just happily curious whether anyone had tried or if it was even remotely possible. I’ll have to see if I can dig up an old copy of 2010. How about for x64 support?
MSVC2010 has x64 support, don’t forget to install Service Pack 1 for Visual Studio – it has fixes for x64
don’t forget to install Service Pack 1 for Visual Studio
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.
Hello, there,
Thanks for sharing this, however I got an error when I tried to install Qt 5.6.2 with visual studio 2015. Here is my error:
After using configure -debug-and-release -opensource -platform win32-msvc2015;
command line told me:
NMAKE : fatal error U1077: ‘”C:\Program Files (x86)\Microsoft Visual Studio 14.0
\VC\BIN\link.EXE”‘ : return code ‘0x486’
Stop.
Could not find output file ‘arch.exe’ or ‘arch’ in C:/Qt/5.6.2/qtbase/config.tes
Can you give me some ideas for this?
Thanks a lot.. Worked fine with Qt 5.5
please update article for qt 5 and visual studio 2018
I tried compiling QT 5.2.0 with VS 2010 x64.
I run configure with -debug-and-release flag,
after it finished, and after running jom, I cannot find the xxxd.dll (all the debug DLLs) so I cannot debug my applications with this library.
(with release everything is working as expected.)
any idea how can I get those debug DLLs?
thanks!
please update article for qt 5 and visual studio 2018