gcc - 无法编译程序集 :/usr/bin/ld: i386 architecture of input file `array1.o' is incompatible with i386:x86-64 output

标签 gcc assembly x86 nasm

这个问题在这里已经有了答案:





Assembling 32-bit binaries on a 64-bit system (GNU toolchain)

(2 个回答)


4年前关闭。




我正在使用 Kali linux 64 位,我正在尝试从 Paul Carter 博士的网站执行以下程序。 gcc 命令给出错误。我应该在 gcc 命令中使用什么?

nasm -f elf32 array1.asm
root@kali:assembly# gcc -o array1 array1.o array1c.c
array1c.c:9:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
array1c.c:10:1: warning: ‘cdecl’ attribute ignored [-Wattributes]
/usr/bin/ld: i386 architecture of input file `array1.o' is    incompatible    with i386:x86-64 output
collect2: error: ld returned 1 exit status

最佳答案

您正在尝试链接 32 位目标文件 i386到 64 位可执行文件 ( i386:x86-64 )。添加 -m32gcc编译行以创建 32 位可执行文件。

关于gcc - 无法编译程序集 :/usr/bin/ld: i386 architecture of input file `array1.o' is incompatible with i386:x86-64 output,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31369916/

相关文章:

c++ - GCC 运行时库与 Microsoft Visual C++ 运行时可再发行组件

assembly - JNZ 和 CMP 组装说明

linux - x86 汇编语言 - 如何读取输入的字符数?

c - 如何确定堆栈中保存的值?

C++ Lambda 生成的 ASM 代码

assembly - 如何指定 x86 和 PowerPC 指令的执行时间?

c++ - GCC 内联汇编 : call dword ptr

c++ - std::packaged_task 应该删除带有 const 参数的拷贝 c'tor

c++ - 使用 vector 按分隔符拆分字符串 - 如何按换行符拆分?

assembly - 使用十六进制在汇编代码中编写指令