Search code examples
visual-c++64-bitvisual-c++-2005

LNK1112 module machine type 'X86' conflicts with target machine type 'x64' (VC++ 2005)


I am trying to build a blank, 64-bit C++ application in Visual Studio 2005 Professional using these steps:

  1. Create a new Win32 Console Application project
  2. Go to Configuration Manager, create new Solution Platform of type x64, copy settings from Win32
  3. Save & build

However, I get this error:

LINK : fatal error LNK1104: cannot open file 'kernel32.lib'

So, I tried updating the library directories to point to kernel32.lib:

  1. Go to Project Properties, Linker, General, Additional Library Directories and set "C:\Program Files\Microsoft Visual Studio 8\VC\lib\amd64"
  2. Save & build

This gives me the error:

LINK : fatal error LNK1104: cannot open file 'user32.lib'

So, I tried updating the library directories to point to user32.lib:

  1. Go to Project Properties, Linker, General, Additional Library Directories and add "C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64"
  2. Save & build

But now I am getting the error:

.\x64\debug\stdafx.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

Any ideas what I am doing wrong?


Solution

  • Must've been a broken installation of Visual Studio. A new installation of Windows and VS2005 fixed the problem.