How to add includepath in Makefile when building in bash command line?

Hi, all:

I'm wondering is there a way to specify includepath while building Arduino programs? Most of the time, I found people copy Arduino programs down to Arduino default installation path, say /usr/share/arduino/libraries/. That's not what I want..

Is there a way to put my own programs at my specified directory, but I can set some includepath to specify the route for some adopted header files? I dropped a similar question at http://arduino.cc/forum/index.php/topic,155293.msg1164190.html#msg1164190, but the answer is no. But this is C language anyway. Isn't there a way out? I'm using a bash, instead of an Arduino IDE. There must be some way out, I think.

Help, please Pei

jiapei100: Hi, all:

I'm wondering is there a way to specify includepath while building Arduino programs? Most of the time, I found people copy Arduino programs down to Arduino default installation path, say /usr/share/arduino/libraries/. That's not what I want..

Is there a way to put my own programs at my specified directory, but I can set some includepath to specify the route for some adopted header files? I dropped a similar question at http://arduino.cc/forum/index.php/topic,155293.msg1164190.html#msg1164190, but the answer is no. But this is C language anyway. Isn't there a way out? I'm using a bash, instead of an Arduino IDE. There must be some way out, I think.

GCC has a bunch of environment variables that if set, affect where it searches for things. Since Arduino tends to use 4.3.2, here is the 4.3.x manual page for the appropriate environment variables: http://gcc.gnu.org/onlinedocs/gcc-4.3.6/gcc/Environment-Variables.html#Environment-Variables

In partciular:

CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH Each variable's value is a list of directories separated by a special character, much like PATH, in which to look for header files. The special character, PATH_SEPARATOR, is target-dependent and determined at GCC build time. For Microsoft Windows-based targets it is a semicolon, and for almost all other targets it is a colon. CPATH specifies a list of directories to be searched as if specified with -I, but after any paths given with -I options on the command line. This environment variable is used regardless of which language is being preprocessed.

The remaining environment variables apply only when preprocessing the particular language indicated. Each specifies a list of directories to be searched as if specified with -isystem, but after any paths given with -isystem options on the command line.

In all these variables, an empty element instructs the compiler to search its current working directory. Empty elements can appear at the beginning or end of a path. For instance, if the value of CPATH is :/special/include, that has the same effect as `-I. -I/special/include'.

Add -I to the command to compile the sketch, compile the .cpp of the library (with the same options as the arduino core and such) and then add the generated .o file to the avr-ar line.

It might be helpful for you to say exactly how you’re compiling your sketch rather than just “in bash”