question about the -I option

Dan Hipschman dsh@linux.ucla.edu
Sat Jan 27 04:33:00 GMT 2007


On Fri, Jan 26, 2007 at 06:33:34PM -0800, maser rati wrote:
> I have this directory structure:
> 
>           test
>          /   \
>        /       \
> hello.c     include
>                  \
>                   hello.h
> 
> hello.c contains #include <include/hello.h>
> if I would need to compile hello.c into an executable,
> does this sound right ?
> 
> [root@localhost test]# gcc -I ./include/ hello.c 
> 
> I'm getting an error:
> hello.c:2:27: error: include/hello.h: No such file or
> directory

Either use ``#include <include/hello.h>'' with ``gcc -I . hello.c'', or
``#include <hello.h>'' with ``gcc -I include hello.c'', or (what you
probably want) use double quotes (") instead of angle brackets around
the file name.

In your example, the compiler is looking for ./include/include/hello.h,
and it's also looking for include/hello.h in the system directories.
You might want to follow this link if you're new to C:

http://c-faq.com/cpp/inclkinds.html



More information about the Gcc-help mailing list