View Full Version : Library Path

11-09-2004, 09:23 AM

I'm trying to compile a C project with GCC. Meanwhile I want to use other "include" files rather than the system ones. I've tryed to use the -I switch, but it didn't work. Isn't there a environment variable that can be set to the libraries path I want? And if it exists, how do I change it - in a Linux environment?

Best regards,


jim mcnamara
11-09-2004, 11:22 AM
From the man page for cpp (the gcc preprocessor)

-I dir
Add the directory dir to the list of directories to be searched for
header files.

Directories named by -I are searched before the standard system
include directories.

It is dangerous to specify a standard system include directory in
an -I option. This defeats the special treatment of system headers
. It can also defeat the repairs to buggy system headers which GCC
makes when it is installed.


#include "somefile.h"

quoted files names forces cpp to look for somefile.h using the "-I directory" specification first. Filenames in trackets "<>" are assumed to be in the standard include directory.

gcc -I. -Wall myfile.c -o myfile
will find somefile.h in your current working directory before it looks anywhere else.