最近我升级到了 gcc-4.9,但它完全破坏了我的 clang++,我无法编译任何东西。我得到的错误是:
In file included from src/tester.cpp:11:
In file included from /usr/include/boost/progress.hpp:22:
In file included from /usr/include/boost/timer.hpp:20:
In file included from /usr/include/boost/config.hpp:40:
In file included from /usr/include/boost/config/select_stdlib_config.hpp:18:
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/cstddef:51:11: error: no member named 'max_align_t' in the global namespace
using ::max_align_t;
clang++ -v 的输出:
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.1
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
我尝试卸载 gcc 和 clang 并重新安装,但没有帮助。你对如何修复它有什么建议吗?
答案1
$ grep max_align_t /usr/include/c++/* -r
/usr/include/c++/4.9/cstddef: using ::max_align_t; /usr/include/c++/4.9.2/cstddef: using ::max_align_t; /usr/include/c++/v1/cstddef: max_align_t /usr/include/c++/v1/cstddef:typedef long double max_align_t;
/usr/include/c++/v1/ 是来自 libc++-dev 的文件,所以我们需要 clang 来使用 libc++
简单的编译器开关可以解决这个问题
因此,如果您收到此错误,请将其添加到您的 clang 命令行:-stdlib=libc++
答案2
几个月来,clang 和 gcc 之间存在一个长期存在的 ABI 不兼容错误。该问题导致 clang 无法与现有系统库链接。
好消息(截至 2016-07-27)是:该问题已在 Xenial (16.04.1 LTS) 中修复
对于那些对细节感兴趣的人来说,上游的错误是: