【发布时间】:2016-07-13 19:48:16
【问题描述】:
我正在尝试在 64 位 Windows 中编译和链接 32 位程序。 我用 nasm 编译了我的程序
nasm -f win32 test.asm
编译成功。但是当我尝试与 link.exe 链接时
link /entry:start /subsystem:console test.obj Kernel32.lib
或
link /machine:x86 /entry:start /subsystem:console test.obj Kernel32.lib
它给了我这个错误:
C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64\Kernel32.lib : warnin
g LNK4272: library machine type 'x64' conflicts with target machine type 'X86'
test.exe : fatal error LNK1120: 3 unresolved externals
但是当我编写 32 位版本的 Kernel32.lib 的绝对路径时,它链接成功。我想我应该将 32 位 Kernel32.lib 的位置作为路径变量添加到某处,或者我应该使用开关但我找不到它。
有没有不写绝对路径的链接方式?
【问题讨论】:
-
使用
/libpath设置路径? -
是的,它可以工作,但我正在尝试将此信息永久提供给链接器。 (作为环境变量)。我的意思是链接器必须了解 .obj 文件是 32 位的,并且它必须查找 32 位版本的库。我不明白为什么这会发生在我的电脑上。 VS 和 Windows 与其他计算机相同,但它只发生在我身上。而且我确定我没有更改其他项目的链接器配置。(我还使用 dumpbin 检查了 .obj 文件头,它们是 32 位的。)
-
请不要将解决方案编辑到问题中。您对已接受答案的评论是该评论唯一归属的地方。
-
好吧,我重新编辑了。