If you are happen to be using GCC
or CLANG
, the standard way is having the environment variable CPLUS_INCLUDE_PATH
with the path of the non-official includes files and LIBRARY_PATH
for the libraries. Remind that you do not have to change anything in the configure.ac. So you can just call the configure in this way:
$ export CPLUS_INCLUDE_PATH=/opt/local/include
$ export LIBRARY_PATH=/opt/local/lib
$ ./configure
The facto standard variables
Variable | lang | Usage
-------------------|------|---------
C_INCLUDE_PATH | C | colon separated list of include directory paths
CPLUS_INCLUDE_PATH | C++ | colon separated list of include directory paths
LIBRARY_PATH | C/C++| colon separated compiling time static linking dirs
LD_RUN_PATH | C/C++| colon separated compiling time dynamic linking dirs
LD_LIBRARY_PATH | C/C++| colon separated run-time dynamic linking dirs
CPPFLAGS | C/C++| prepocessor flags
CFLAGS | C | Compiling flags
CXXFLAGS | C++ | Compiling flags
LDFLAGS | C++ | Linking flags
NOTE You can use CPPFLAGS
or LDFLAGS
, however, CPLUS_INCLUDE_PATH
/LIBRARY_PATH
exactly fits your requirement. CPPFLAGS/LDFLAGS
are for flags which can be many things but *_PATH
are for PATHs
Portability Note: While this will work on many modern compilers, not all compilers will respect these variables. Some cross-compilers will outright ignore or overwrite them, which forces one to resort to CFLAGS
and LDFLAGS
modifications as mentioned in other answers.
SOURCE Might the downvotes here be because of the lack of sources in my answer. Here is for CPLUS_INCLUDE_PATH
in GCC: https://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html