我使用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,但没有成功。请告诉我:什么是“模块机类型”,什么是“目标机类型”?我怎样才能克服它呢?
当前回答
我通过在Visual Studio 2013中将Win32更改为*64来解决这个问题。
其他回答
"project property - CUDA Runtime API - GPU - NVCC Compilation Type"
设置64位编译选项-m64 -cubin
提示是在编译日志。 是这样的:
nvcc.exe ~~~~~~ -machine 32 -ccbin ~~~~~
“- 32号机器”是个问题。
第一个设置64位编译选项, 下一步重新设置混合编译选项。 然后你就能看到成功。
当我遇到这个令人抓狂的问题时,我写了一篇关于这个问题的博客文章,并最终将我的系统恢复到正常工作状态。
以下是需要检查的事项,按顺序:
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位的目标。
这是一个非常令人沮丧和讨厌的问题,但一旦你理解了它,它就很简单了:你在构建一种架构类型(在你的情况下是x64)中有一些元素,尽管它是另一种类型(比如x86)的目标。
您可以通过查看哪个obj文件导致崩溃来分析问题的根源,并开始在那里寻找问题。每个obj将有一个源代码模拟:要么在cpp, c, asm等。可能有一些特殊的构建事件使用了错误的工具。在属性表中查看。
我会先看看那里,然后再看C·约翰逊的待办事项清单。
我在构建QT时遇到了这个问题,我在某处读到的说明建议我使用VS命令提示符配置nmake。
我选择了x64命令提示符并轻松地执行了配置。当我尝试nmake时,它给出了这个错误。
我想有些组件是为32位系统预建的。这个错误甚至报告了哪些模块是为x86构建的。
我使用32位默认的VS命令提示符,它工作。
模块机类型是您正在编译的机器,目标机类型是您正在为其构建二进制文件的x86或x64架构。