Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding out what the GCC include path is [duplicate]

I'm trying to programmatically find the #include path on Linux, which as I understand it, in practice means finding what GCC considers it to be. (Is that quite true? How does Clang do it?)

According to http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html some of the components involve the CPU architecture and the GCC version; the latter in particular seems tricky; I suppose it could be obtained by running gcc --version and parsing the output (or gcc -v), but this seems inelegant at best and fragile at worst. Doing it from within one's code assuming one's program is being compiled with GCC might be another option, but it would require depending on that assumption.

What's the recommended way to do it?

like image 502
rwallace Avatar asked Jul 30 '13 06:07

rwallace


People also ask

How do I find the GCC path?

You need to use the which command to locate c compiler binary called gcc. Usually, it is installed in /usr/bin directory.

Where does g ++ look for include files?

GCC looks for headers requested with #include " file " first in the directory containing the current file, then in the directories as specified by -iquote options, then in the same places it would have looked for a header requested with angle brackets.

Where is include path?

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 ¶

How do I change the include path?

Expand C/C++ General and select Paths and Symbols. Click here to see an illustration (displayed in a separate window). Click Add to define new element (Include Path, Symbol, Library path etc). Click Edit to change selected element (Include Path, Symbol, Library path etc).


1 Answers

The command

echo | gcc -E -Wp,-v - 

will show the include path in use.

like image 70
caf Avatar answered Oct 05 '22 07:10

caf