我使用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,但没有成功。请告诉我:什么是“模块机类型”,什么是“目标机类型”?我怎样才能克服它呢?
当前回答
除了Jhonson的列表,还可以查看图书馆的文件夹
在visual studio中,从主菜单中选择Tools > Options。选择项目和解决方案> vc++目录。从平台下拉菜单中选择x64。
$(VCInstallDir)lib\AMD64;
$(VCInstallDir)atlmfc\lib\amd64;
$(WindowsSdkDir)lib\x64;
其他回答
模块机类型是您正在编译的机器,目标机类型是您正在为其构建二进制文件的x86或x64架构。
当我遇到这个令人抓狂的问题时,我写了一篇关于这个问题的博客文章,并最终将我的系统恢复到正常工作状态。
以下是需要检查的事项,按顺序:
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位的目标。
由于问题是由于编译和目标机器规格(x86 & x64)的差异造成的 遵循以下步骤:
打开要配置的c++项目。 选择“配置管理器”按钮,打开“配置管理器”对话框。 在“主用解决方案平台”下拉列表中,选择相应的选项,打开“新建解决方案平台”对话框。 在“类型或选择新平台”下拉列表中选择64位平台。
它解决了我的问题。
我的目标是一个x64 Windows 10文本模式的DOSBox应用程序在C语言。 使用“Visual Studio 2019 Community”通过DOS提示符“nmake -f makefile”进行编译。 错误是类似的,但在相反的方面:
fatal error LNK1112: module machine type 'x32' conflicts with target machine type 'X64'
在另一台计算机上用vc++ 2010编译是可以的。但是“Visual Studio 2019社区”在这台计算机上失败了。所以我的设置是正确的,以上所有答案都不工作。
我想和大家分享的解决方案是这样的make.bat:
call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
nmake -f makefile
你会发现还有很多其他的vcvarxxxx .bat,只有这一个词。
在Visual Studio 2012 +/-中,“配置属性”. linker的属性页。“命令行”包含一个标记为“附加选项”的框。如果您正在构建x64,请确保该方框不包含/MACHINE:I386。我的项目是这样做的,它产生了问题中的错误。