I have few header files in /my/path/to/file folder. I know how to include these files in new C program but everytime I need to type full path to header file before including it. Can I set some path variable in linux such that it automatically looks for header files ?
Share
You could create a makefile. A minimal example would be:
From here you could improve this makefile in many ways. The most important, probably, would be to state compilation dependencies (so only modified files are recompiled).
As a reference, here you have a link to the GNU make documentation.
If you do not want to use makefiles, you can always set an environment variable to make it easier to type the compilation command:
Then you could compile your program like:
You may want to define
MY_INC_PATHvariable in the file.bashrc, or probably better, create a file in a handy place containing the variable definition. Then, you could usesourceto set that variable in the current shell:I think, however, that using a makefile is a much preferable approach.