gcc 编译过程问题
写个hello.c 程序,
生成
hello.c -> 预处理 gcc -E hello.c -o hello.i 执行没问题;
预处理 -> 汇编 gcc -S hello.i -o hello.s 执行也没问题;
汇编 -> 目标文件 gcc -c hello.s -o hello.o 执行也没问题;
目标文件 -> 可执行文件 gcc hello.o -o hello 执行报了这个错误,如下:
hello.o: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o:(.fini+0x0): first defined here
hello.o: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o:(.data+0x0): first defined here
hello.o:(.rodata+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o:(.rodata+0x0): first defined here
hello.o:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o:(.rodata.cst4+0x0): first defined here
hello.o: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o:(.text+0x0): first defined here
hello.o: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o:(.init+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
hello.o:(.data+0x8): first defined here
/bin/ld: error in hello.o(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status
???
但运行 hello.o 已经可以执行了。
正在回答 回答被采纳积分+1
- 参与学习 521 人
- 提交作业 288 份
行业热门,政策风口,人才缺口极大,现在入场时机正好! 上千人检验,数轮迭代的硬核知识体系,0基础友好入行/转行 保姆式教学+简历指导+1V1模拟面试+3次内推,助力轻松就业!
了解课程

恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星