【问题标题】:undefined reference to `__gthrw___pthread_key_create with gcc 4.8.4 and Eclipse Luna使用 gcc 4.8.4 和 Eclipse Luna 对 `__gthrw___pthread_key_create 的未定义引用
【发布时间】:2017-02-22 14:00:08
【问题描述】:

我使用 gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4 和 Eclipse CDT 版本:Luna Service Release 2 (4.4.2)。

我的程序不使用任何库,而不是 pthread 和更近的 gthread。它使用 C++11 标准,通过 C++-Compiler 选项中的方言下拉菜单进行设置。

g++ 的 GCC 链接器产生以下错误:

./src/main.o:(.rodata+0x1e8): 未定义引用 `__ghrw___pthread_key_create(unsigned int*, void ()(void))'

我已经搜索过如何禁用弱符号引用,但并不幸运。

谁能给点建议?

【问题讨论】:

    标签: eclipse c++11 gcc


    【解决方案1】:

    发现它与g++-4.8有某种关系。

    我安装了g++-5,错误消失了。

    步骤如下:

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    sudo apt-get update
    sudo apt-get install g++-5 libstdc++-5-dev
    
    sudo rm -f /usr/bin/g++
    sudo ln -s /usr/bin/g++-5 /usr/bin/g++
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-17
      • 1970-01-01
      • 2018-05-07
      • 2017-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      相关资源
      最近更新 更多