Domanda

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?

È stato utile?

Soluzione 2

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

Altri suggerimenti

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

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top