Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
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

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
The -I option is your friend, if you need to specify a non-standard include directory for compiling purposes. It's used like this:
Code:
gcc -I/path/to/include/directory file.ext
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.