【问题标题】:GCC : picking up wrong version of headersGCC:选择错误版本的标头
【发布时间】:2012-11-29 07:07:49
【问题描述】:

我下载并开始构建 LLVM / CLANG。我最初安装了 gcc 版本 4.1.2 20080704(Red Hat 4.1.2-48),但 LLVM 网站声明使用更高版本。所以我下载并编译/构建了 GCC gcc 版本 4.7.2 (GCC)。现在我在设置以下配置后开始构建 LLVM:

# setenv PATH /usr/local/lib:/usr/local/lib64:$PATH
# setenv LD_LIBRARY_PATH /usr/local/lib/:/usr/local/lib64/
# setenv CC /usr/local/bin/gcc

注意 GCC 4.1.2 可用的路径是 /usr/bin 而 4.7.2 我默认在 /usr/local/bin 找到它

但是 LLVM 构建失败说明:

In file included from /x/home/satprasad/llvm/llvm-3.1.src/projects/compiler-rt/lib/asan/asan_posix.cc:35:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/algorithm:64:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_algobase.h:69:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:45:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/c++io.h:38:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr.h:132:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:100:1: error: weakref declaration must have
      internal linkage
__gthrw(pthread_once)

但它应该为 4.7.2 版本而不是 4.1.2 版本选择文件/标题 - 请告诉我如何解决这个问题 - 给出错误的行位于文件/代码下方:

llvm-3.1.src/projects/compiler-rt/lib/asan/asan_posix.cc

#include <algorithm>

提前致谢

【问题讨论】:

  • 我在 CentOS 上也遇到了这个问题。不完全相同的症状,但使用 gcc 4.7.2。我放弃并下载了 rpm,它工作正常。

标签: gcc llvm clang glibc


【解决方案1】:

跑步:

./configure --help

显示此选项:

--with-gcc-toolchain 安装gcc的目录。

那就试试吧:

--with-gcc-toolchain /usr/local

并且不要设置任何环境变量。

【讨论】:

  • 我建议您在LLVM mailing list 上提问。
  • 我没有得到完整的具体选项,但使用 DESTDIR=/usr 安装最新的 GCC 或使用 --prefix=/usr 进行配置解决了这个问题。请注意,这样我只能使用最新版本的 GCC。链接中提到了其他方法:gcc.gnu.org/faq.html#multiple 但由于对于较旧的我没有任何代码、二进制文件或 RPM,我重新安装了最新的
  • @Prakash 好吧,你现在几乎把你的系统搞砸了。您不应该安装到 /usr。这是为通过包管理器安装的软件保留的。例如,现在您可能会被操作系统更新覆盖的文件。而且没有真正的清理方法,因为您无法卸载手动安装的软件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-01
  • 2012-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-21
相关资源
最近更新 更多