How can I query the default include path of clang/clang++? I am trying to use a custom built clang compiler (the one that supports OpenMP), but it doesn't seem to find the STL libraries:
/usr/local/bin/clang++ hello.cpp hello.cpp:1:10: fatal error: 'iostream' file not found #include <iostream> ^ 1 error generated.
By using an IDE, back-tracking the #include iostream, and finally using the -isystem option I got the simple helloworld application to compile in OSX 10.9:
/usr/local/bin/clang++ -isystem /Library/Developer/CommandLineTools/usr/lib/c++/v1 hello.cpp
Thanks for your help!
You need to use the which command to locate c compiler binary called gcc. Usually, it is installed in /usr/bin directory.
System include paths are standard locations to find source code tags, such as the header files in /usr/include and its subdirectories on Unix-like operating systems. You can add and remove system include paths using the following commands: Command: semantic-add-system-include dir &optional mode ¶
The -cc1 argument indicates that the compiler front-end is to be used, and not the driver. The clang -cc1 functionality implements the core compiler functionality. So, simply speaking. If you do not give -cc1 then you can expect the "look&feel" of standard GCC.
Some header files ( stddef. h , stdarg. h , and others) are shipped with Clang — these are called builtin includes. Clang searches for them in a directory relative to the location of the clang binary.
You are looking for option -v
. Compiling with clang++ -c file.cc -v
will print among other things:
#include "..." search starts here: #include <...> search starts here: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9
etc.
If you run
clang++ -### hello.cpp
It will display the commands used to compile that particular file, including the default include paths, library search paths, targets etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With