How to query the default include paths of clang++?
Asked Answered
S

2

38

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!

Scaleboard answered 14/5, 2014 at 12:1 Comment(0)
M
49

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.

Maroc answered 14/5, 2014 at 15:25 Comment(1)
You may also use -H option to print headers used for compiling a particular file.Whereunto
N
15

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.

Niche answered 31/7, 2021 at 19:51 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.