I have 2 machines, both of which have the same copy of code. Both the machines are installed with the same Visual Studio, VS2013 ultimate version.
The code is a QT project with lots of Windows APIs. So, qmake
will generate Makefile
, Makefile.Debug
and Makefile.Release
. These Makefile
are the same on both machines.
In Makefile.Debug
and Makefile.Release
, the actual compiler and linker are VS's cl and link
. The difference between the 2 machines is, one is Windows 10, and the other is Windows 8.1. But both machines are 64-bit machine.
The problem is, on Windows 10 machine, the build progress in QT Creator passes, but on Windows 8.1 machine, there will be one error while building.
Firstly, the error was "xxx.dll: LNK1112: module machine type 'x64' conflicts with target machine type 'x86'"
. I know here "xxx.dll"
is indeed 'x64'
type, and I realized that the Windows 8.1 machine thinks the "target machine type" is X86
, so I modified Makefile.Debug
manually by adding "/MACHINE:X64" to LINKFLAG
. This action changed the error to become "yyy.obj: module machine type 'x86' conflicts with target machine type 'x64'"
. Yeah, this time the VS's link knows the target machine should be 'x64', but it looks like VS's compiler still compile some cpp file to be 32-bit .obj file.
My question is, why VS's cl
thinks it should make a 32-bit obj file rather than a 64-bit obj file? And, how to let VS's cl
make a 64-bit obj?
I checked the cl command on both machines. They are the same like below.
cl -c -nologo -Zc:wchar_t -FS -Zi -MDd -GR -W3
-w34100 -w34189 -w44996 -EHsc /Fd..\<some folder>
-DXXX -IYYY -Fodebug\ @C:\Users\someuser>\AppData\Local\Temp\ZZZ.obj.8160.63.jom ZZZ.cpp
Visual Studio provides different compilers (i.e. cl.exe binaries) for different architectures.
Check which compiler actually gets called by QT creator (for x64 architecture it should be the <MS VS Dir>/VC/bin/amd64/cl.exe
). I am guessing that it is either coming from a default setting in your environment (PATH
variable) or that you have to setup QT Creator correctly to build for the right architecture.