Where are header files for GCC located?

36,348

Solution 1

First take a look in /usr/include or /usr/local/include.

If you find nothing there, try :

`gcc -print-prog-name=cc1plus` -v

This command asks gcc which C++ preprocessor it is using, and then asks that preprocessor where it looks for includes.

You will get a reliable answer for your specific setup.

Likewise, for the C preprocessor:

`gcc -print-prog-name=cc1` -v

Solution 2

To look for header locations just use the locate command:

locate -b '\math.h'
locate -b '\graphics.h'

or a simpler approach

locate \*/math.h
locate \*/graphics.h

If you are more familiar with regular expression use

locate -r \/math.h$

To make sure the database is up-to-date start:

sudo updatedb

That's the way I'm searching my headers location. It's much faster than using the find command.

Share:
36,348

Related videos on Youtube

Chirag Soni
Author by

Chirag Soni

Updated on September 18, 2022

Comments

  • Chirag Soni
    Chirag Soni over 1 year

    I want to manually add some header files like math.h and graphic.h for gcc but don't know where to put them.

  • Knud Larsen
    Knud Larsen about 6 years
    math.h should already be present. Example : /usr/include/c++/7.3.0/math.h
  • user001
    user001 over 4 years
    How does the backslash act to prevent matching by files with preceding characters in their basename? The string \math.h should evaluate to math.h, but I see that \math.h avoids matching files like tgmath.h and quadmath.h.
  • abu_bua
    abu_bua over 4 years
    FROM 'man locate' : To search for a file named exactly NAME (not *NAME*), use locate -b '\NAME' Because \ is a globbing character, this disables the implicit replacement of NAME by *NAME*.
  • user001
    user001 over 4 years
    Thanks. I had checked man locate, but I guess I have a different version of the locate(1) man page (which doesn't have one instance of \ ).
  • abu_bua
    abu_bua over 4 years