我有rfact.s和rfactmain.c
rfact.s:
.text
.p2align 4
.global rfact
.type rfact, @function
rfact:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $4, %esp
movl 8(%ebp), %ebx
movl $1, %eax
cmpl $1, %ebx
jle .L53
leal -1(%ebx), %eax
movl %eax, (%esp)
call rfact
imull %ebx, %eax
.L53:
addl $4, %esp
popl %ebx
popl %ebp
ret
rfactmain.c:
int main(){
int x = rfact(4);
return 0;
}
我在64位系统上。所以首先我通过
获取两个目标文件gcc -m32 -c rfact.s
gcc -m32 -c rfactmain.c
然后我尝试将它们链接在一起
gcc -m32 -o rf rfact.o rfactmain.o
但是我收到了错误
gcc -m32 -o rf rfact.o rfactmain.o
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib64/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib64/libc.a when searching for -lc
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
如果我删除-m32我得到错误(由于两个目标文件都是32位,这是预期的)
gcc -o rf rfact.o rfactmain.o
/usr/bin/ld: i386 architecture of input file `rfact.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `rfactmain.o' is incompatible with i386:x86-64 output
collect2: error: ld returned 1 exit status
答案 0 :(得分:1)
您没有安装32位支持的东西。您可能需要单独使用gcc-multilib软件包或32位库软件包。请查阅您的发行版文档和/或包管理器。