C++ 需要更改 clang 的包含路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21363494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Need to change include path for clang
提问by Humble Debugger
When building with clang, it seems to be using gcc4.4.4 version of include files, while I want it to use newer ones.
使用 clang 构建时,它似乎使用 gcc4.4.4 版本的包含文件,而我希望它使用更新的文件。
[ ~ ] locate move.h
/home/apps/gcc_versions/gcc-4_8_install/include/c++/4.8.3/bits/move.h
/usr/include/c++/4.4.4/bits/move.h
/usr/local/include/c++/4.7.1/bits/move.h
gcc path :
gcc 路径:
`gcc -print-prog-name=cc1plus` -v
ignoring nonexistent directory "/apps/gcc_versions/gcc-4_8_install/lib/gcc/x86_64-unknown-linux-gnu/4.8.3/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/apps/gcc_versions/gcc-4_8_install/lib/gcc/x86_64-unknown-linux-gnu/4.8.3/../../../../include/c++/4.8.3
/apps/gcc_versions/gcc-4_8_install/lib/gcc/x86_64-unknown-linux-gnu/4.8.3/../../../../include/c++/4.8.3/x86_64-unknown-linux-gnu
/apps/gcc_versions/gcc-4_8_install/lib/gcc/x86_64-unknown-linux-gnu/4.8.3/../../../../include/c++/4.8.3/backward
/apps/gcc_versions/gcc-4_8_install/lib/gcc/x86_64-unknown-linux-gnu/4.8.3/include
/usr/local/include
/apps/gcc_versions/gcc-4_8_install/include
/apps/gcc_versions/gcc-4_8_install/lib/gcc/x86_64-unknown-linux-gnu/4.8.3/include-fixed
/usr/include
End of search list.
And gcc includes work fine But with clang it fails
并且 gcc 包括工作正常但是使用 clang 它失败了
[ ~ ] clang -v
clang version 3.5 (http://llvm.org/git/clang.git 8e674ff884113429b53d23b18409caf67aaec1b7) (http://llvm.org/git/llvm.git 7add5421a686877e0aa87616b92b1f5a85c6feee)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
I am a newbie at this and please suggest if some info is missing that would help to resolve this.
我是这方面的新手,如果缺少一些有助于解决此问题的信息,请提出建议。
回答by Zizheng Wu
Try compiling as following,
尝试编译如下,
clang++ -isystem /SOMEPATH/gcc-4.9.2/include/c++/4.9.2 -I/SOMEPATH/gcc-4.9.2/include/c++/4.9.2/x86_64-unknown-linux-gnu a.cpp
clang++ -isystem /SOMEPATH/gcc-4.9.2/include/c++/4.9.2 -I/SOMEPATH/gcc-4.9.2/include/c++/4.9.2/x86_64-unknown-linux-gnu a.cpp