C++ – How to compile a 64-bit native C++ DLL in VS 2008

64-bitcvisual studiovisual-studio-2008

I'm trying to port a native ATL C++ in-proc COM server to 64 bit in Visual Studio 2008. I've opened the Configuration Manager, added "x64" platform. Now I have 6 configurations – 3 for Win32 that compile and link fine and 3 for x64 that compile fine, but make the linker emit the following error:

\Debug64\Objects\common.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

what do I change to make this go away?

UPD: Resolved, the problem source was surprisingly dumb, see my answer below.

Best Answer

Did you install the "x64 compiler and tools" component during the visual studio installation?

Also check these settings: (copied from msdn)

  • /MACHINE (Specify Target Platform) is set to /MACHINE:IA64 or /MACHINE:X64.

  • Register Output is turned OFF. For more information, see Linker Property Pages.

  • Target Environment is set to /env x64 or /env ia64. For more information, see MIDL Property Pages: General.

  • Validate Parameters is cleared and reset to the default value. For more information, see MIDL Property Pages: Advanced.

  • If Debug Information Format was set to /ZI in the Win32 project configuration, then it is set to /Zi in the 64-bit project configuration. For more information, see /Z7, /Zi, /ZI (Debug Information Format).

  • Values of WIN32 are replaced by WIN64 for /D (Preprocessor Definitions).

Related Topic