开发者

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

开发者 https://www.devze.com 2022-12-25 14:18 出处:网络
I am using VS 2003 .Net on 32 bit XP OS. I have also installed \"Microsoft Platform SDK\" on my machine. Can I build vc++ application (binaries) targeted for 64 bit OS?

I am using VS 2003 .Net on 32 bit XP OS. I have also installed "Microsoft Platform SDK" on my machine. Can I build vc++ application (binaries) targeted for 64 bit OS?

I am using following project options :

    Name="VCLinkerTool"
    AdditionalOptions="/machine:AMD64 bufferoverflowU.lib"
    OutputFile="\bin\Release\MM64.dll"
    LinkIncremental="1"
    SuppressStartupBanner="TRUE"
    AdditionalLibraryDirectories=""C:\Program Files\Microsoft Platform SDK\Lib\AMD64""
    GenerateDebugInformation="TRUE"
    ProgramDatabaseFile="\bin\Release\MM64.pdb"
    GenerateMapFile="TRUE"
    MapFileName="\bin\Release\MM64.map"
    MapExports="TRUE"
    MapLines="TRUE"
    OptimizeReferences="2"
    EnableCOMDATFolding="2"
    ImportLibrary=".\Release/MM64.lib"
    TargetMachine="0"/>

I am getting following error:

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

Do I need to build project on 64 bit OS or I need to change project settings to resolve thi开发者_C百科s error. Please help me to resolve this issue.


I had the same problem today, here's how I solved it (in Visual Studio 2008): Went to Project Properties -> Linker -> Command Line -> Additional Options and removed the /MACHINE:I386 from the linker additional options.

Hope it helps


Having the same problem in VS2008. My solution was to change the active solution platform located in Build -> Configuration Manager and creating a new solution platform using the x64 and copuing the settings from Win32. This allowed me to use the pre-build 32bit libraries in my 64 bit OS.


For 64-bit Windows users:

I had the same problem today, here's how I solved it (in Visual Studio 2008): I went to:

Project Properties -> Linker -> Command Line -> Additional Options

and added the /MACHINE:I364 from the linker additional options.

This worked fine for me.


I faced above error when I tried to build my custom library for ARM64 in Visual Studio 2017. And my target machine was already ARM64 as expected.

Apparently, problem was in ARM64 compiler which was not installed(though I could run build in ARM64). I installed it by running Visual Studio Installer Individual Components -> Visual C++ compiler and libraries for ARM64

Next I got error MSB8022: Compiling Desktop applications for the ARM platform is not supported.
It was resolved by adding

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
  ...
  <PlatformToolset>v141</PlatformToolset>
  <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
</PropertyGroup>

into my project file. After all of above I could succefully build my project in ARM64.

Hope it will be useful.


This error comes up because something in you build is being compiled in the wrong architecture (say as a x86 binary when everything else is x64). The linker panics and doesn't know what to do with it, so it breaks your build. I can speak for your problem because the error message you quoted is incomplete. Usually it goes something like this:

SOME_KIND_OF_OBJECT.obj: fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'AMD64'

You look at the name of the obj file and you'll find the root of your problem there. Whatever obj is listed will have some kind source code analog with the same name. Have a look at it and see how it's being compiled. Usually all that stuff is automated in VS but sometimes there are special build steps that were added in by the developer. Inspect the custom, pre- and post- build events to see if a x86 tool is being used to assemble it. The property sheet in VS2010+ will be specific to the obj and the platform so you can inspect the library directories being used to verify that they are not 32 bit.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号