How to link a non-standard header file into a C compiler

I'm trying to use a non-standard header file ( Its used in lots of codes in various different places on my computer. Currently I have to put the header file and the object file in every folder which its needed with the preprocessor directive:

#include "gnuplot_i.h"

In the file. Is there a way by which I can put the header file in one place so I can reference it like other standard header file. Cheers.


Compile with -I<directory>


compile with -I/usr/local/gnuplot/inc.

Also it might be worth your reading up on include paths and the difference between:

#include <include_file.h>


#include "include_file.h"

Linking in an object file needs to be done explicitly the same way as a C file, which means (I believe) that you need a full path. However if you archive it into a proper library then you can use -l<library name> and -L<library path> instead. E.g.

gcc -I/usr/local/gnuplot/inc -L/usr/local/gnuplot/lib -lgnuplot -o my_prog my_prog.c

Need Your Help

Finding file path with os.walk

python filepath os.walk

I have a set of files saved in my laptop. The folder structure is like: