Chinaunix

标题: gcc和ld不兼容的问题 [打印本页]

作者: wanas    时间: 2007-01-17 14:35
标题: gcc和ld不兼容的问题
我写了一个Hello.c,在redhat as3上,结果ld过不去。
提示
/usr/local/bin/ld: unrecognized option '--eh-frame-hdr'
/usr/local/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status

我查看/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs,链接部分这么写的:
*link:
%{!static:--eh-frame-hdr} -m elf_i386 %{shared:-shared}   
%{!shared:     %{!ibcs:       %{!static:      %{rdynamic:-export-dynamic}
%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}  %{static:-static}}}

我怀疑是%{!static:--eh-frame-hdr}这个参数不被ld兼容。查看版本:

gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20)
GNU ld version 2.11.2 (with BFD 2.11.2)

请各位帮帮我,我是初学者。
作者: wanas    时间: 2007-01-17 14:46
gcc -c hello.c 能够通过,生成hello.o
作者: strongzgy    时间: 2007-01-17 18:28
标题: 回复 #2 wanas 的帖子
可能你需要升级一下 binutils了。
我的ld --help 显示有--eh-frame-hdr选项。所以可能是你的ld版本低,不认识 eh-frame-hdr
我的ld版本是2.16.1
作者: langue    时间: 2007-01-17 19:03
%{!static:--eh-frame-hdr} -m elf_i386 %{shared:-shared}


用 -static 试试看行不。实在不行,把 binutils 升级到 2.16

再试着把红色的部分去除(这个我没有试过)

====
作者: wanas    时间: 2007-01-18 09:09
谢谢2位!

不知道何gcc version 3.2.3 配合的ld 用哪个版本号?

我现在的是:
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20 Kernel 2.4.21)
GNU ld version 2.11.2 (with BFD 2.11.2)
作者: langue    时间: 2007-01-18 18:36
旧了,试试看 2.16 系列的。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2