I am trying to compile the Qt library (I don't need the demos or examples) for 64-bit Windows. There are instructions here but I run into the error described in the comment below it. There doesn't seem to be a reference anywhere for how one might go about doing this process.
I am targetting Microsoft Visual C++ 2010 Express. It looks like I need Perl and the Windows SDK as well - how do I go about this process?
This process is quite tedious and time-consuming - but I will explain each step in detail here for the benefit of others who try to compile Qt in the future.
The first step is to install all of the prerequisites.
Download the Qt source archive from the Qt Downloads page.
Extract the contents of the archive to an easy-to-remember location (like
C:\
). You need to remember this location later since we will be using it to set some environment variables.Now open the Windows SDK 7.1 Command Prompt. Begin by setting the environment to 32-bit release mode (we need to build some of the tools as 32-bit applications):
Set the following environment variables (example below assumes you extracted to
C:\
):Now run
cd %QTDIR%
and specify the configuration options - example is included below:Once the configuration process is complete,
cd
to thesrc
directory and run:This process may take a considerable amount of time, so now would be a good time to take a break and answer some questions here on Stack Overflow :)
The tools are now built and you need to compile Qt as a 64-bit library. Enter the following command:
You will need to set the environment variables from step 5 again. Enter those commands now.
Run
cd %QTDIR%
and then rerun theconfigure
command being sure to specify one additional option:The
-no-qmake
option is very important - it indicates that we want to skip the compilation of theqmake.exe
program because we want to keep the 32-bit version.Now things get really complicated here because of some dependency problems. The tools (like
moc
) that Qt needs to build the core library and some of the other components are listed as dependencies in thesrc.pro
file. This means that the compiler will attempt to build them as 64-bit applications and then try to run them - which will of course fail on a 32-bit system. So what we need to do is editsrc.pro
and remove those dependencies ourselves. Scroll down near line 85 and look for a line that begins with:Each subsequent line in the section lists a sub-target and its dependencies. What you want to do now is remove all dependencies that begin with
src_tools_
. For example:Becomes:
There might be a better way of doing this, but I haven't figured it out yet :)
Now we
cd
into thesrc
directory once again and run the following commandThis builds only the Qt libraries and skips the tool dependencies. Note that this too may take a considerable amount of time.
You should now have 64-bit libraries in the
lib
folder that you can link against in your 64-bit Qt applications.Edit: it turns out that even this wasn't enough since I still ran into some problems when linking the
QtWebKit4.dll
library (something about unresolved symbols). It turns out that someone else has already found the solution and you need to changeQMAKE_HOST.arch
toQMAKE_TARGET.arch
inWebCore.pro
.Also, the above options will build QNetwork4.dll without OpenSSL support (you won't be able to access sites over HTTPS - even in a QWebView). This, thankfully isn't too hard to fix. Download and build OpenSSL for Win64 and append the options below to the command in step #9:
(You'll have to change the paths if you installed OpenSSL somewhere other than
C:\OpenSSL
.)Further edit: to save the trouble of doing this yourself, I have uploaded the compiled libraries here:
http://www.box.com/s/9710cbb278ef4890a7b5
As I mentioned in the comments to George Edison's answer, there is a bug in the Microsoft Visual C++ compiler that comes with the Windows SDK 7.1. For more information on this, see QTBUG-11445 and QTBUG-19175.
I have compiled the Qt 4.8.2 64-bit binaries following George's instructions, including the OpenSSH library. In addition, I applied Microsoft's hotfix to fix the compiler bug.
For your convenience, I have made the resulting 64-bit libraries available for download from here: https://www.box.com/s/8948c60c3cdd743ef83b