Getting Qt5.1.1 to work in Visual Studio 2012 Professional on Win 7 64 bit
I'm new here to the forum, and I hope that this hasn't been answered elsewhere. I've googled quite a bit, but nothing I try seems to work. I figured I would ask here since its the Qt homeplace. Anyway, here's what I've done so far:
1)I'm on Windows 7 64 bit
- Installed Visual Studio 2012 Professional - (with Update 3) [this works fine on normal projects]
- Installed the following version of Qt:
3a) Qt 5.1.1 for Windows 64-bit (VS 2012, OpenGL, 522 MB) (Info)
3b) This came with QtCreator which creates/builds/runs a new Qt GUI Project fine
- Downloaded and Installed "Visual Studio Add-in 1.2.2 for Qt5"
So far so good.
I open Visual Studio 2012 and see that it seems to have installed successfully. I have the QT5 drop down on the file menu. So, I do the following:
//Add Qt Version - This is the location with the bin\qmake.exe
QT5 -> Qt Options -> Add -> I set path to "C:\Qt\Qt5.1.1\5.1.1\msvc2012_64_opengl"
So I create a new basic GUI Qt project with a single mainwindow form. I don't edit anything, as I just want to see if it'll run. When I build the project, it gives the following error:
Error 2 error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' C:\Users\xxxxxx\Documents\Visual Studio 2012\Projects\QtTest\QtTest\Qt5Widgets.lib(Qt5Widgets.dll) QtTest
I've tried the following:
- Configuration Manager -> "Active solution platform" dropdown -> change to X64.
When I rebuild, it throws a window's exception saying "There's no Qt version assigned for the platform x64."
- Project -> <project_name> Properties -> Configuration Properties -> Linker -> Advanced -> Target Machine -> Changed it from "MachineX86 (/MACHINE:X86)" to "MachineX64 (/MACHINE:X64)".
All this does is switch the error message when building to "Error 2 error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' C:\Users\xxxxxx\Documents\Visual Studio 2012\Projects\QtTest\QtTest\Release\qrc_qttest.obj 1 1 QtTest
Well, I'm out of ideas. Did I download the correct bit version of Qt? I'm assuming not since QtCreator works fine as it seems. I'm also not very knowledgeable on these types of errors.
Ideally, while I am working off a 64 bit machine, I would think I would want to build 32 bit programs as I want my other personal computer and my professor's computer to be able to run the compiled program.
Partial Solution / Update!
So, I downloaded and installed the 32 bit version of the library from the download page:
Qt 5.1.1 for Windows 32-bit (VS 2012, 511 MB) (Info)
When i set the path to it in VS2012 as my default and create a new project, everything works fine. No errors, it builds, and it runs.
So.... I don't know why I can't get the 64 bit version to run through VS2012, but I'm ok with the 32 bit library for now. I guess if I want 64 bit application, I can just use QtCreator (64 bit) and do it there.
Maybe this will help somebody.
I got tripped up on this as well. The solution is:
- Right click on the project.
- Select "QT Project Settings" (Almost at the bottom of the long popup.)
- Click on "Version" (at bottom) and select the right version.
- Click on "Qt Modules" tab and select the modules you wish to use.
Thanks for the reply GatoRat. However, I still cannot use my 64 bit 5.1.1 library with VS2012.
The "version" you mention is simply the path to the */bin/qmake.exe. I have both versions (x86 and 64) in that list. While the x86 version seems to work, when I try to use the x64 library, it throws the error in the original post. If for some reason I needed a x64 application built and wanted to use VS2012, do you have any other ideas.
Note: QtCreator (from x64) library works so I could always use that, but I'd prefer VS.
I am just now setting up a project for 64-bit and the "Version" in QT Project Settings is the name from Qt Versions in Qt Options. (These are two different dialogs.)