views:

30

answers:

2

We're currently using qmake and .pro files to create projects for Visual Studio 2008, but the default solution platform is Win32. Every time the projects are rebuilt, I have to manually change the platform to x64 by going into the configuration manager and copying settings from the Win32 solution.

I have not been able to find online/QT forums a way to automatically create a VS2008 solution configured for a x64 build. Do I need to create my own makespec for QT? Do I need to specify x64-specific VS flags? Does anyone have an example they can post which they've successfully used for creating x64-spec projects?

A: 

This is a known issue. There are a couple of relevant bugs in the Qt bugtracker: QTBUG-6910 and QTBUG-4046. This second entry also has a link to a patch that you can use if you are building Qt yourself. Vote for those bugs to be fixed to increase the visibility of this issue.

the_mandrill
Thanks, I used the patch 3891 from the second link and compiled QT from source. Then, I added contains(QMAKE_HOST.arch, x86):{QMAKE_LFLAGS *= /MACHINE:X86}contains(QMAKE_HOST.arch, x86_64):{QMAKE_LFLAGS *= /MACHINE:X64}to my qmake files and it worked! Kind of a pain... but knowing how to build QT from source helped a lot, even though it's only 2 commands.
whiskers
A: 

Thanks to the_mandrill, this is the solution:

First, you need to download patch 3891. Then, you need to apply the patch - you could find a patch utility for windows, but I just edited the files diffed in the patch manually; the files are in \qmake\generators\win32

Then, you need to build QT from scratch, which is done by navigating in command prompt (make sure it's the Visual Studio 2008 x64 command prompt from the Visual Studio directory) to the directory you installed QT in, presumably C:/QT/4.7.0, and typing configure, then nmake.

Building QT will take a long time. In the meantime, adding these to your qmake files will automatically detect your host OS. Keep in mind that this solution does NOT produce both win32 and x64 configurations on x64 - only the x64 configuration.

contains(QMAKE_HOST.arch, x86):{
QMAKE_LFLAGS *= /MACHINE:X86
}

contains(QMAKE_HOST.arch, x86_64):{
QMAKE_LFLAGS *= /MACHINE:X64
}

This produces a working x64 Visual Studio solution that compiles and links without errors.

whiskers