gcc的静态编译错误

in3o

我正在尝试编译以下代码:

#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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章