【问题标题】:What's with 'ld'?“ld”是怎么回事?
【发布时间】: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
  • 对。或者如果只是使用ldld -o file file.o -melf_i386

标签: ubuntu assembly ld


【解决方案1】:

这是因为您的系统架构。我认为您使用的是 64 位 CPU 和 64 位操作系统。要解决此问题,请尝试将 elf 替换为 elf64。有关更多信息,请运行以下命令: nasm -hf

【讨论】:

    猜你喜欢
    • 2011-07-21
    • 1970-01-01
    • 2017-10-20
    • 2013-07-06
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-30
    相关资源
    最近更新 更多