【问题标题】:Boost linking error undefined reference to GLIBCXX_3.4Boost 链接错误未定义对 GLIBCXX_3.4 的引用
【发布时间】:2014-01-09 03:20:21
【问题描述】:

我正在尝试与 boost 链接,在 ubuntu 下使用 clang。我收到以下错误:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_filesystem.a(operations.o): undefined reference to symbol '_ZNSs4_Rep10_M_destroyERKSaIcE@@GLIBCXX_3.4'
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我已将 find_package(Boost COMPONENTS file_system, system) 添加到 cmake。知道什么可能导致此错误吗?

【问题讨论】:

标签: c++ boost cmake


【解决方案1】:

这个错误是因为 Boost 是使用 gcc 标准库 libstdc++ 构建的,而我是使用 clang libc++ 编译的。

之前我使用的是通过 apt-get 下载的 Boost。从 boost.org 下载源代码并使用 clang 及其标准库手动编译解决了这个问题。

【讨论】:

  • 我收到了类似的消息,当从 g++ 切换到 clang++ 时,我不小心输入了 clang(仅 C/自动编译器,这意味着它不喜欢正确到libc++)。
猜你喜欢
  • 2021-03-30
  • 1970-01-01
  • 2018-03-05
  • 2020-06-19
  • 1970-01-01
  • 2013-04-01
  • 2022-01-01
  • 2017-05-02
  • 2013-05-16
相关资源
最近更新 更多