Click to See Complete Forum and Search --> : compiler unable to locate header file


lamicedaxeh
03-22-2003, 01:01 PM
OS: debian woody
compiler version : gcc 2.95.4

Hi folks,

Trying to compile a program, but keep getting "no such file or directory". The file is the header file "gnome.h", who's location is part of my PATH variable. I tried supplying the absolute path using the "L" switch but still the compiler is unable to locate it!

example:

gcc -o my_progam_name -L /my_location/to./header/file ./*

Thanks

Bill

bwkaz
03-22-2003, 07:12 PM
PATH is not searched for include files.

Include files have their own path thingy, but it's not an environment variable -- you pass -I/path/to/containing/directory (that's a capital i, BTW) to gcc to add a directory to the include path list.

So if the header file was in /home/user/include (which is not in the system include file search path -- that's /usr/include plus /usr/lib/gcc-lib/<arch>/<gcc version>/include), you could compile a program that used it like:

gcc -o program program.c -I/home/user/include

-L is for library files, which are completely different from headers. You need them both (headers and the associated library) to make the code work, though. But they're in different directories -- for example, system libs are in /usr/lib, while system includes are in /usr/include.

lamicedaxeh
03-23-2003, 08:27 AM
First, thank you bwkaz for ur help and time :) Secondly, if u don't mind a second ( there's alway one more :D ) question! How do u supply more than one include directory?

example:

gcc -o my_file_name -I /usr/include/gnome-1.0:/usr/include/gtk-1.2/gtk ./*

or

gcc -o my_file_name -I /usr/include/gnome-1.0 /usr/include/gtk-1.2/gtk ./*

or

gcc -o my_file_name -I /usr/include/gnome-1.0 -I /usr/include/gtk-1.2/gtk ./*


Do u use the colon ":" to separate the arguments or simply a space between them or use the "I" switch for each directory or some completely different?

Many thanks

Bill

bwkaz
03-23-2003, 09:41 AM
You use two -I switches. Same with the library path -- if you need two directories in it, use two -L switches.

lamicedaxeh
03-23-2003, 05:29 PM
Thanks bwkaz :)