Need to change include path for clang

Humble Debugger picture Humble Debugger · Jan 26, 2014 · Viewed 32.4k times · Source

When building with clang, it seems to be using gcc4.4.4 version of include files, while I want it to use newer ones.

[ ~ ] 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 -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

[ ~ ] 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.

Answer

Zizheng Wu picture Zizheng Wu · Nov 10, 2014

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