Adding an include directory to gcc *before* -I

天大地大妈咪最大 提交于 2019-12-11 09:57:11

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17510472/adding-an-include-directory-to-gcc-before-i

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!