I want to manually add some header files like math.h and graphic.h for gcc but don't know where to put them.
- 151
- 1
- 1
- 7
2 Answers
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
- 1,477
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.
Finding headers in not installed packages
For sake of completeness I post a one liner script which is in my mind very useful in finding apt packages involving a special header file.
#!/usr/bin/env bash
apt-file search $1 | cut -f 1 -d ":" | sort -u
Save this one liner for instance in your ~/.local/bin directory as e.g. aptfilesearch and make it executable with chmod +x aptfilesearch. Now you get a list of all packages including the header file you are searching for. Here a simple demonstration:
aptfilesarch math.h
- 11,313