我正在尝试编译以下代码:
#include<stdio.h>
void func()
{
printf("In function\n");
return ;
}
int main()
{
printf("In mains\n");
func();
return 0;
}
使用gcc -static -o try try.c
但出现以下错误:
/usr/bin/ld: error: hidden symbol '__ehdr_start' is not defined locally
/usr/bin/ld: error: hidden symbol '__ehdr_start' is not defined locally
/usr/bin/ld: error: hidden symbol '__ehdr_start' is not defined locally
/usr/bin/ld: error: hidden symbol '__ehdr_start' is not defined locally
/usr/bin/ld: error: hidden symbol '__ehdr_start' is not defined locally
collect2: error: ld returned 1 exit status
我做错什么了吗?
我有的Gcc版本是 gcc version 4.7.2 (Debian 4.7.2-5)
看看Binutils Released。看来,如果您拥有binutils 2.24.51.0.2
或更早的版本,则可能需要进行更新以避免带有__ehdr_start
符号的错误。具体地说,它看起来像从binutils 2012 0806更新为ELF文件头添加了对__ehdr_start符号的支持。然后在2.24.51的更新中,修复了与__ehdr_start相关的错误。
我在openSuSE上具有2.23.2版本,但没有看到任何问题,在Archlinux机器上也有2.24,并且在那里没有看到问题。因此,问题似乎与binutils 2012 0806发行版和2.24.51之间的版本有关。
很高兴您能解决。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句