Ever wondered where does gcc looks for the include files on Linux

Ever wondered where does gcc looks for the include files on Linux

Type this command

$ $(gcc -print-prog-name=cc1) -v

and you get a result like this

ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../i486-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /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.

For details on cc1 which is the c compiler proper. Refer this link

This command can be extended for arm based gcc like arm-linux-gcc

$ $(arm-linux-gcc -print-prog-name=cc1) -v

and an example looks like this

ignoring nonexistent directory "/home/prajosh/toolchain/SAM9G20/buildroot-2011.05/output/host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/local/include"
ignoring nonexistent directory "/home/prajosh/toolchain/SAM9G20/buildroot-2011.05/output/host/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.4.6/../../../../arm-unknown-linux-uclibcgnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/prajosh/toolchain/SAM9G20/buildroot-2011.05/output/host/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.4.6/include
 /home/prajosh/toolchain/SAM9G20/buildroot-2011.05/output/host/usr/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.4.6/include-fixed
 /home/prajosh/toolchain/SAM9G20/buildroot-2011.05/output/host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include
End of search list.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s