Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

GCC has built in include directories for certain standard headers. I just need to know where this list is. My newly compiled gcc will not compile my little test C++ program because it cannot find standard headers. I think it fails because of some config options I used to make my file system more organized. I set the bindir and libdir, which I think might have screwed up the built-in include paths for some reason.

Program (dummy.c):

#include <iostream>
void main(){}

Command:

g++ dummy.c

Error:

dummy.c:1:20: fatal error: iostream: No such file or directory
share|improve this question

1 Answer 1

up vote 4 down vote accepted

The preprocessor can tell you what it uses

cpp -x c++ -v

...

    #include "..." search starts here:
    #include <...> search starts here:
     /usr/include/c++/4.4
     /usr/include/c++/4.4/i486-linux-gnu
     /usr/include/c++/4.4/backward
     /usr/local/include
     /usr/lib/gcc/i486-linux-gnu/4.4.1/include
     /usr/lib/gcc/i486-linux-gnu/4.4.1/include-fixed
     /usr/include/i486-linux-gnu
     /usr/include
    End of search list.

You can add directories to the search path by setting the C_INCLUDE_PATH and/or CPLUS_INCLUDE_PATH environment variiables

share|improve this answer
    
ah great, I was looking for some way to actually print those out. Now I know for certain that they are screwed up. –  Charles Jun 2 '10 at 21:09
1  
It appears that later versions of gcc don't have a default specs file to read from, but can generate one for later customisation. There is more discussion about this here –  Iain Jun 3 '10 at 9:02
    
I made some customizations to my specs file to add the real include directories and I can now compile. Usually I would not let such a hack fly but this is a temp toolchain anyway, thanks! –  Charles Jun 3 '10 at 13:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.