我使用CUDA (vc++, Visual studio 2008sp1)来调试FEM程序。由于cuda的不足,该程序只能在Win32平台上运行。我认为链接的库文件都是在x86平台上编译的,但是当我编译它时,我得到了错误消息
致命错误LNK1112:模块机类型“x64”与目标机类型“X86”冲突。
我曾尝试将该平台转换为x64,但没有成功。请告诉我:什么是“模块机类型”,什么是“目标机类型”?我怎样才能克服它呢?
我使用CUDA (vc++, Visual studio 2008sp1)来调试FEM程序。由于cuda的不足,该程序只能在Win32平台上运行。我认为链接的库文件都是在x86平台上编译的,但是当我编译它时,我得到了错误消息
致命错误LNK1112:模块机类型“x64”与目标机类型“X86”冲突。
我曾尝试将该平台转换为x64,但没有成功。请告诉我:什么是“模块机类型”,什么是“目标机类型”?我怎样才能克服它呢?
当前回答
vcxproj文件可能包含“MACHINE:i386” 用编辑器编辑vcxproj文件。把它拿掉!
其他回答
所有的项目设置看起来都很完美,但我仍然得到了错误。查看.vcxproj文件并搜索“x86”就会发现问题:
<Lib>
<AdditionalOptions> /machine:X86 %(AdditionalOptions)</AdditionalOptions>
</Lib>
快速搜索/替换所有出现的情况(10个单独的文件设置)解决了这个问题。
在我的例子中,将环境变量PROCESSOR_ARCHITECTURE设置为AMD64 修复了问题。
https://social.msdn.microsoft.com/Forums/en-US/f9303904-81ce-405d-85b3-b66d97e49971
首先尝试以下几点: 1. 进入配置管理器,并创建一个新的x64,如果它已经不在那里。 2. 选择x64解决方案。 3.进入项目属性,然后链接器->高级选择x64机器。 4. 现在重新构建解决方案。
如果你仍然得到相同的错误。尝试干净的解决方案,然后重新构建,再次打开visual studio,您将获得最近打开的项目列表,右键单击该项目并将其从那里删除。现在转到解决方案并再次重新打开解决方案。
在Visual Studio 2013中,
1)检查项目属性页/配置属性/链接器/所有选项,并纠正所有未配置的机器和目录。
2)检查项目属性页/配置属性/链接器/输入,并纠正所有未配置的目录。
参见示例1)
当我遇到这个令人抓狂的问题时,我写了一篇关于这个问题的博客文章,并最终将我的系统恢复到正常工作状态。
以下是需要检查的事项,按顺序:
Check your properties options in your linker settings at: Properties > Configuration Properties > Linker > Advanced > Target Machine. Select MachineX64 if you are targeting a 64 bit build, or MachineX86 if you are making a 32 bit build. Select Build > Configuration Manager from the main menu in visual studio. Make sure your project has the correct platform specified. It is possible for the IDE to be set to build x64 but an individual project in the solution can be set to target win32. So yeah, visual studio leaves a lot of rope to hang yourself, but that's life. Check your library files that they really are of the type of platform are targeting. This can be used by using dumpbin.exe which is in your visual studio VC\bin directory. use the -headers option to dump all your functions. Look for the machine entry for each function. it should include x64 if it's a 64 bit build. In visual studio, select Tools > Options from the main menu. select Projects and Solutions > VC++ Directories. Select x64 from the Platform dropdown. Make sure that the first entry is: $(VCInstallDir)\bin\x86_amd64 followed by $(VCInstallDir)\bin.
一旦我完成了第4步,一切都恢复正常了。问题是我在我所有的项目中都遇到了这个问题,我想编译一个64位的目标。