【发布时间】:2013-07-09 08:41:49
【问题描述】:
我是汇编新手,在 linux 中创建可执行文件时遇到问题, 我有这个汇编代码将它保存为 file.asm 并使用终端编译它:
nasm -f elf file.asm
ld -o file file.o" // the problem lies here. I always get this notice:
ld: i386 architecture of input file 'file.o' is incompatible with i386:x86-64"
所以,我无法继续运行该文件。这可能是因为我的 ubuntu 版本,但我认为不是。 :(我不知道。帮助。
【问题讨论】:
-
-f elf是-f elf32的简写。尝试改用-f elf64。或者,如果您真的想构建一个 32 位应用程序,您可以使用类似这样的链接:gcc -m32 -o test test.o -
对。或者如果只是使用
ld、ld -o file file.o -melf_i386。