Jeremy Dunck
Jeremy Dunck

Reputation: 5894

Adding an include directory to gcc *before* -I

From the docs:

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.

On my machine, I'd like to e.g. cross-compile or, otherwise have an versioned set of alternative includes. I'd like to use those to compile other people's code.

Concretely, I have several different versions of python, and their related Python.h files.

$ python setup.py pillow fails because the include it finds first isn't the one needed. (/usr/local/include has an old Python.h, but I need /usr/local/include/Python2.7 to "win").

Adding /usr/local/include/Python2.7 to CPATH (or C_INCLUDE_PATH) doesn't work because it's placed later.

As far as I can see, this isn't python-specific -- surely there's a way to force GCC to have paths prior to -I / CPATH?

Upvotes: 1

Views: 529

Answers (1)

technosaurus
technosaurus

Reputation: 7812

Its a bit hacky, but you can add it to your compiler var

Makefile syntax

 CC = gcc -Ipath

Or

 export CC="gcc -Ipath"

Or g++ for the CXX variable.

Upvotes: 1

Related Questions