简体   繁体   English

链接问题:致命错误 LNK1112:模块机器类型“x64”与目标机器类型“X86”冲突

[英]linking problem: fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

Im trying to run sample app from wxFreeChart library.我试图从 wxFreeChart 库运行示例应用程序。 After compilation on linking there is an error:编译链接后出现错误:

wxcode_msw28d_freechart.lib(wxfreechart_lib_xydataset.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

I tried to switch linker option\\advanced\\target machine to MachineX64 but it doesnt work.我试图将链接器选项\\高级\\目标机器切换到 MachineX64,但它不起作用。

Im using visual studio 2008, any suggestion ?我正在使用 Visual Studio 2008,有什么建议吗?

thanks for help感谢帮助

The error is explicit, you are trying to link libraries that were compiled with different CPU targets.错误很明显,您正在尝试链接使用不同 CPU 目标编译的库。 An executable image can only contain pure x86 (32-bit) or pure x64 (64-bit) code.可执行映像只能包含纯 x86(32 位)或纯 x64(64 位)代码。 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.您可以通过为项目创建新配置来更改目标 CPU,仅更改链接器设置是不够的。 Build + Configuration Manager, Active solution platform combo on upper right, choose New and select x64.构建 + 配置管理器,右上角的活动解决方案平台组合,选择新建并选择 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.请注意,在 VS2010 之前,默认情况下不会安装 64 位编译器。 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.如果在平台组合中没有看到 x64,则需要重新运行 setup.exe 并打开安装 64 位编译器的选项。 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.一种具有较少痛点的可能方法是使用该库的 32 位版本。

I bumped into this too and found a solution.我也遇到了这个问题并找到了解决方案。

First on how I got into this problem.首先谈谈我是如何陷入这个问题的。 I have a project which builds in x86.我有一个在 x86 中构建的项目。 Then I used the Configuration Manager to add x64, and I hit this problem.然后我使用配置管理器添加x64,我遇到了这个问题。

By looking at BuildLog.htm carefully, I saw both of these listed as linker options:通过仔细查看BuildLog.htm ,我看到这两个都被列为链接器选项:

/MACHINE:X64  
/machine:X86 

I could not find anywhere in the Property Pages dialog where I could change this, so I opened up the .vcproj file and looked for the appropriate line and changed it to:我在“属性页”对话框中找不到可以更改此设置的任何位置,因此我打开了.vcproj文件并查找了相应的行并将其更改为:

AdditionalOptions=" /STACK:10000000 /machine:x64 /debug"

and problem solved.并解决了问题。

转到项目属性-> 配置属性-> 图书管理员将目标机器设置为 MachineX64 (/MACHINE:X64)

In my case it appears it was because I had "copied settings" from a 32-bit to a new configuration (64 bit) and it hadn't updated the libraries.就我而言,这似乎是因为我将 32 位的“设置”“复制”到了新的配置(64 位),并且它没有更新库。 Odd.奇怪的。

1>MSVCRTD.lib(ti_inst.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' 1>MSVCRTD.lib(ti_inst.obj):致命错误 LNK1112:模块机器类型“X86”与目标机器类型“x64”冲突

this meant “your properties -> VC++ Directories -> Library Directories” is pointing to a directory that has 32 bit libs built in it.这意味着“您的属性 -> VC++ 目录 -> 库目录”指向一个内置 32 位库的目录。 Fix somehow!以某种方式修复!

In my case http://social.msdn.microsoft.com/Forums/ar/vcgeneral/thread/c747cd6f-32be-4159-b9d3-d2e33d2bab55在我的情况下http://social.msdn.microsoft.com/Forums/ar/vcgeneral/thread/c747cd6f-32be-4159-b9d3-d2e33d2bab55

ref: http://betterlogic.com/roger/2012/02/visual-studio-2010-express-64-bit-woe参考: http : //betterlogic.com/roger/2012/02/visual-studio-2010-express-64-bit-woe

Since the problem is due to the difference in compilation and target machine specifications (x86 & x64) Follow the steps below:由于问题是由于编译和目标机器规格(x86 & x64)不同造成的,请按照以下步骤操作:

  1. Open the C++ project that you want to configure.打开要配置的 C++ 项目。
  2. Choose the Configuration Manager button to open the Configuration Manager dialog box.选择“配置管理器”按钮以打开“配置管理器”对话框。
  3. In the Active Solution Platform drop-down list, select the option to open the New Solution Platform dialog box.在活动解决方案平台下拉列表中,选择打开新建解决方案平台对话框的选项。
  4. In the Type or select the new platform drop-down list, select a 64-bit platform.在类型或选择新平台下拉列表中,选择 64 位平台。

This solved my problem.这解决了我的问题。

Try changing every occurence of .\\Release into .\\x64\\Release in the x64 properties.尝试在 x64 属性中将 .\\Release 的每次出现更改为 .\\x64\\Release。 At least this worked for me...至少这对我有用......

I know this is a bit old, but I thought I would provide another tip.我知道这有点旧,但我想我会提供另一个提示。 In my situation, I inherited this application that I had to maintain.在我的情况下,我继承了这个必须维护的应用程序。 The VS2008 project came with the same string in C/C++->OutputFIles->"ObjectFIleName" and "Program Database File Name" (for both platforms Win32 and x64). VS2008 项目在 C/C++->OutputFIles->"ObjectFIleName" 和 "Program Database File Name"(Win32 和 x64 平台)中带有相同的字符串。 So when I built Win32 platform, it built fine, but when I tried to build x64, I got the error:因此,当我构建 Win32 平台时,它构建得很好,但是当我尝试构建 x64 时,出现错误:

\\Debug64\\Objects\\common.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' \\Debug64\\Objects\\common.obj:致命错误 LNK1112:模块机器类型“X86”与目标机器类型“x64”冲突

Obviously, both patforms were storing common.obj at the same location, so when I tried to build x64, the linker took the existing object file, which was x86.显然,两个模式都将 common.obj 存储在同一位置,因此当我尝试构建 x64 时,链接器采用了现有的目标文件,即 x86。

To fix I just replaced the existing string with the macro "$(IntDir)\\" for x64 (no quotes), and made sure that the macro resolved to the correct path, as in the rest of the projects.为了解决这个问题,我只是用 x64 的宏 "$(IntDir)\\" 替换了现有的字符串(没有引号),并确保宏解析到正确的路径,就像在其他项目中一样。 That solved my problem.那解决了我的问题。

An update to i00g's and Thomas' answers, this time for VS2012 (some names have changed).更新 i00g 和 Thomas 的答案,这次是针对 VS2012(某些名称已更改)。 After copying x86 settings over into an x64 target with the configuration manager, you'll have the problem for the same reason as was the case earlier (lib targets aren't correct in the x64 config).使用配置管理器将 x86 设置复制到 x64 目标后,您将遇到与之前情况相同的问题(lib 目标在 x64 配置中不正确)。 Open your .vcxproj (text editor) and replace MachineX86 with MachineX64 where appropriate.打开您的 .vcxproj(文本编辑器)并在适当的地方用 MachineX64 替换 MachineX86。 (I still haven't found where this is on the property sheets....) This only seems to be necessary with static libs. (我仍然没有在属性表上找到它的位置......)这似乎只对静态库是必要的。

before going for the step " compile -DIPLIB=NONE filename.cxx " take the path of VIsual Studio installation upto the vcvarsall batch file and change the configuration as shown below.在执行步骤“ compile -DIPLIB=NONE filename.cxx ”之前,将 VIsual Studio 安装路径带到 vcvarsall 批处理文件并更改配置,如下所示。

*C:\\apps\\MVS9\\VC\\vcvarsall.bat x86_amd64* *C:\\apps\\MVS9\\VC\\vcvarsall.bat x86_amd64*

now next step should be现在下一步应该是

compile -64bit -DIPLIB=none filename.cxx编译 -64bit -DIPLIB=none filename.cxx

this solved the problem for me这为我解决了问题

Thanks for the answers guys.谢谢各位的回答。 My problem was that I changed a x64 solution in Visual Studio to 32 bit in the Configuration Manager only.我的问题是我仅在配置管理器中将 Visual Studio 中的 x64 解决方案更改为 32 位。 I ended up just creating a new solution as 32 bit and then copying my C++ code and this error was gone.我最终只是创建了一个 32 位的新解决方案,然后复制了我的 C++ 代码,这个错误就消失了。 I think l00g33k and RogerAttrill's suggestions may have been the solution, but mine worked, too.我认为 l00g33k 和 RogerAttrill 的建议可能是解决方案,但我的也奏效了。

Recently,I also encountered this problem.最近,我也遇到了这个问题。 That's because I used qt( x64 ) in vs win32 .那是因为我在 vs win32使用了 qt( x64 ) 。 If you want to use qt application x64 , you could choose vs x64 --as the above.如果您想使用 qt 应用程序x64 ,您可以选择 vs x64 -- 如上所述。 If you want to use win32 and perhaps you haven't,you need to download qt( 32bit ),then correctly set your enviroment, such as the lib directory, etc.(note: maybe you are is old set in x64(other version) , if you convert your win32 or x64 into another, Additional Dependencies includes the old directory!)如果你想使用win32 ,也许你还没有,你需要下载qt( 32bit ),然后正确设置你的环境,例如lib目录等(注意:也许你是x64(other version)旧设置x64(other version) ,如果您将 win32 或 x64 转换为另一个, Additional Dependencies包括旧目录!)

This problem has nothing to do with the linker, so modifying it's setting won't affect the outcome.这个问题与链接器无关,所以修改它的设置不会影响结果。 You're getting this because I assume you're trying to target x86 but for one reason or another wxcode_msw28d_freechart.lib is being built as an x64 file.你得到这个是因为我假设你试图以 x86 为目标,但出于某种原因或其他原因 wxcode_msw28d_freechart.lib 被构建为 x64 文件。

Try looking at wxcode_msw28d_freechart.lib and whatever source code it derives from.尝试查看 wxcode_msw28d_freechart.lib 及其派生的任何源代码。 Your problem is happening there.你的问题发生在那里。 See if there are some special build steps that are using the wrong set of tools (x64 instead of x86).查看是否有一些特殊的构建步骤使用了错误的工具集(x64 而不是 x86)。

基于这些答案 - 我还必须在 Librarian -> Command Line -> Additional Options (for the x64 Platform) 下修改 X86 参考

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命错误LNK1112:模块机器类型“ x64”与通过vcvarsall.bat x86运行构建的目标机器类型“ X86”冲突 - fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' running build via vcvarsall.bat x86 致命错误 LNK1112:在 npm 安装期间,模块机器类型“X86”与目标机器类型“x64”冲突 - fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' during npm install Qt5Quickd.lib(Qt5Quickd.dll):致命错误LNK1112:模块计算机类型“ x64”与目标计算机类型“ x86”冲突 - Qt5Quickd.lib(Qt5Quickd.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86' LNK1112:模块机器类型“x64”与目标机器类型“X86”冲突:Qt 创建者 - LNK1112: module machine type 'x64' conflicts with target machine type 'X86': Qt creator 链接器错误:1112模块机器类型“ X86”与目标机器类型“ IA64”冲突 - Linker error:1112 module machine type 'X86' conflicts with target machine type 'IA64' Qt-模块机器类型“ x64”与目标机器类型“ X86”冲突 - Qt - module machine type 'x64' conflicts with target machine type 'X86' 库机器类型“ x86”与目标机器类型“ X64”冲突 - library machine type 'x86' conflicts with target machine type 'X64' 模块机器“x64”与目标机器“x86”冲突 - Module machine 'x64' conflicts with target machine 'x86' 错误构建skia:机器类型x64与x86冲突 - Error build skia: machine type x64 conflicts with x86 LNK2001和LNK1120在编译链接x86静态库的x64动态库时 - LNK2001 and LNK1120 when compiling a x64 dynamic library linking a x86 static library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM