报错:ld: i386 架构于输入文件 foo.o 与 i386:x86-64 输出不兼容
或者:ld: i386 architecture of input file `foo.o' is incompatible with i386:x86-64 output
编译链接指令
1
nasm -f elf foo.s -o foo.o
2
gcc -c bar.c -o bar.o
3
ld -s -o foobar bar.o foo.o
汇编语言用nasm编写并用nasm编译器编译,而C语言用的是gcc编译,这些都没有问题,但是在链接的时候出错了,提示如下:
ld: i386 architecture of input file `foo.o' is incompatible with i386:x86-64 output
意思就是nasm 编译产生的是32位的目标代码,gcc 在64位平台上默认