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

linking problem: fatal error LNK1112: module machine type #39;x64#39; conflicts with target machine type #39;X86#39;(链接问题:致命错误 LNK1112:模块机器类型“x64与目标机器类型“X86冲突)

本文介绍了链接问题:致命错误 LNK1112:模块机器类型“x64"与目标机器类型“X86"冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 wxFreeChart 库运行示例应用程序.编译链接后出现错误:

Im trying to run sample app from wxFreeChart library. 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'

我尝试将链接器选项高级目标机器切换到 MachineX64,但它不起作用.

I tried to switch linker optionadvanced arget machine to MachineX64 but it doesnt work.

我正在使用 Visual Studio 2008,有什么建议吗?

Im using visual studio 2008, any suggestion ?

感谢帮助

推荐答案

错误很明显,您正在尝试链接使用不同 CPU 目标编译的库.可执行映像只能包含纯 x86(32 位)或纯 x64(64 位)代码.无法混合.

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.

您可以通过为项目创建新配置来更改目标 CPU,仅更改链接器设置是不够的.构建 + 配置管理器,右上角的活动解决方案平台组合,选择新建并选择 x64.这将创建一个新配置,其中包含几个修改过的项目设置,最重要的是将使用的编译器.

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.

请注意,在 VS2010 之前,默认情况下安装 64 位编译器.如果您在平台组合中没有看到 x64,那么您需要重新运行 setup.exe 并打开安装 64 位编译器的选项.然后重新运行您可能已应用的任何服务包安装程序.

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.

使用 32 位版本的库.

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

这篇关于链接问题:致命错误 LNK1112:模块机器类型“x64"与目标机器类型“X86"冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

基础教程推荐