VC9: LINK : warning LNK4068: /MACHINE not specified; defaulting to X86


fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' 



The error is explicit, you are trying to link libraries that were compiled with different CPU targets. An executable image can only contain pure x86 (32-bit) or pure x64 (64-bit) code. Mixing is not possible.

You change the target CPU by creating a new configuration for the project, only changing the linker setting isn't enough. Build + Configuration Manager, Active solution platform combo on upper right, choose New and select x64. That creates a new configuration with several modified project settings, most importantly the compiler that will be used.

Beware that prior to VS2010, the 64-bit compilers are not installed by default. If you don't see x64 in the platform combo then you'll need to re-run setup.exe and turn on the option to install the 64-bit compilers. Then also re-run any service pack installer you may have applied.

A possible approach with less pain points is to use the 32-bit version of the library.

bumped into this too and found a solution.

First on how I got into this problem. I have a project which builds in x86. Then I use the Configuration Manager to add x64, and I hit this problem.

By looking at BuildLog.htm carefully, I see both of these listed as linker options: /MACHINE:X64

I can't find any where in the Property Pages dialog where I can change this, so I open up the .vcproj file and look for the appropriate line and change it to: AdditionalOptions=" /STACK:10000000 /machine:x64 /debug"


个人分类: 64位
想对作者说点什么? 我来说一句