How To Compile Qt with Visual Studio

February 1, 2011

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.

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.

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).

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 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.

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:

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?

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.

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)

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).

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):

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.

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?

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.

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…?

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.

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?

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…

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.

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!

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.

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?

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.

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

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.

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.

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.

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 :-).

Qt compiled by my instructions can be moved from one computer to another without any problems too.

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.

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:

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

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?

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.

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.

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

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 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.

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.

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.

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

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.

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.

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.

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));

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:

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.

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.

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.

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))

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”):

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).

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.

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:

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

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.

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:

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! 🙂

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:

-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:

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:

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.. 🙂

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!

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:

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

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?

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

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?

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.

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.

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:

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 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 install

8)I strongly recommend using -debug-and-release or you will have troubles debugging in VS2010

9)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;

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.

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).

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.

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.

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.

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!

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.

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

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

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?

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”

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?