Linker Error "LNK1112" - conflicting target types

Last edited on

Symptom

The compilation of Squish from sources on Windows fails with a LNK1112 linker error like this one:

"QtCore4.lib(QtCore4.dll) : fatal error LNK1112: module machine type 'x64' conflicts with
target machine type 'X86' link /NOLOGO /MANIFEST /DLL /MAP /OUT:C:\Src\Squish\bin\fkit.dll
@C:\Src\Squish\bin\fkit.dll.resp C:\qt\4.4.0\lib\QtCore4.lib C:\qt\4.4.0\lib\QtGui4.lib
C:\qt\4.4.0\lib\qtmain.lib wsock32.lib
Aborting build. Last command exited with status 1112"

Cause

The Visual Studio linker has run into an incompatible mix of 32-bit and 64-bit Qt library files. Or, the compiler’s target architecture does not match the Qt installation’s architecture.

Solution

  1. Determine the architecture of the AUT. Is it 32-bit or 64-bit? While doing so don’t confuse the application’s architecture with the operating system’s capabilities. It’s not uncommon to have 32-bit applications running on a 64-bit operating system.

  2. Ensure that the the selected Qt SDK has an architecture matching the one found in 1. This mainly applies to matching pairs of .dll and .lib files for QtCore, QtGui, and other Qt libraries. If in doubt issue dumpbin /headers QtCore4.lib and inspect the output.

  3. Select the version of the compiler matching 1. and 2. Visual Studio has distinct Start Menu entries for 32-bit and 64-bit, respectively. If in doubt about the current environment in a DOS command window issue cl.exe /? and check whether “80x86” or “x64” at the top of its output.