开发者

GCC/G++ equivalent of ldconfig -n

When I create my own non-standard path for library files (say, ~/lib) I can run ldconfig -n ~/lib and this directory is added to the list of locations ld uses to search for non-standard libraries.

Is there a similar switch for GCC/G++ (or an appropriate gcc/++ config manager) related to include directories, and if so, what? I'm aware the -I flag will include non-standard directories, butI'd rather not have to go through all my projects and have to add all forms of magic to the makefiles to make them work -- and then find that these changes are (of course) non-portable to any other system this code is built on (with collaborators, etc), so editing the makefile isn't really an optio开发者_如何学Pythonn....

Edit: Note that my ignorance assumes this solution is gcc/++ only. I'm happy for any solution, however, so if there's a method that abuses some property of ldconfig or whatever, I'm not adverse to it!


Generally, just do man gcc. You'll need -L <path> flag if you are willing to change the Makefiles. There's also a solution similar to ldconfig - to use LIBRARY_PATH env. variable.

Similarly, there's CPLUS_INCLUDE_PATH and C_INCLUDE_PATH and CPATH which are declaring a list of directories to search for header files.


I don't think you can do this with include files, apart from modifying the gcc/g++ source code and recompile it.

The best alternative is adding an alias to your enviroment (if using bash) like:

alias gcc="gcc -Idir1 -Idir2 -Idir3"
alias g++="g++ -Idir1 -Idir2 -Idir3"

or creating an ad-hoc script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜