PDA

View Full Version : Edit Header Search Path of gcc in terminal




ScKaSx
Dec 10, 2007, 03:50 PM
Hi All,

I use gcc in terminal to compile my c/c++ code and I was wondering how to edit where it looks for include files? Naturally, I have afew header files that aren't standard and I want to add a path to the gcc compiler for include files I create and/or use from other sources. Thanks and any suggests will be useful.

Cheers,
ScKaSx
MacBook 10.4.9 Intel



wrldwzrd89
Dec 10, 2007, 04:03 PM
The -I option is your friend, if you need to specify a non-standard include directory for compiling purposes. It's used like this:
gcc -I/path/to/include/directory file.ext

ScKaSx
Dec 10, 2007, 04:45 PM
Thanks for the quick reply.

It's working!
Cheers,
ScKaSx

wrldwzrd89
Dec 10, 2007, 04:49 PM
Thanks for the quick reply.

With the -I option when I reference a header do I need to use quotes ("header.h") or brackets (<header.h>)?

Also, is this a valid -I command (-I~/Programs/include)?

Cheers,
ScKaSx
I'm not sure, but I think you need quotes. Yes, that second command is valid - Mac OS X understands ~ to be the path to your home foler.