0
votes

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?

3
Something is pretty broken in your setup. Sounds to me you've been copying directories to try to fix an earlier problem. Which got possibly started because the VS2005 setup program doesn't install the 64-bit compilers.Hans Passant
@Hans I haven't copied any directories, and VS2005 does give you the option to install the 64-bit compilers: msdn.microsoft.com/en-us/library/ms246588(VS.80).aspxdel

3 Answers

0
votes

It sounds like the problem is with the object file stdafx.obj rather than the system libraries. The warning is saying that stdafx.obj is 32-bit so it can't link into a 64-bit target. Things to try:

  • Delete the build directories x64 and win32
  • Rebuild the project
  • Check the build settings for stdafx.cpp to ensure it's building as 64-bit
0
votes

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

0
votes

Its been long since the question was asked, but for the benefit of others who happen to read this, the change required is in the linker flag setting. Change /machine:I386 to /machine:x64