海湾合作委员会/G++相当于 ldconfig -n
当我为库文件创建自己的非标准路径(例如 ~/lib)时,我可以运行 ldconfig -n ~/lib 并将该目录添加到 ld 用于搜索的位置列表中非标准库。
GCC/G++(或适当的 gcc/++ 配置管理器)是否有与包含目录相关的类似开关,如果有,是什么?我知道 -I
标志将包含非标准目录,但我宁愿不必遍历我的所有项目,也不必将所有形式的魔法添加到 makefile 中以使它们工作 - - 然后发现这些更改(当然)不可移植到此代码所构建的任何其他系统(与合作者等),因此编辑 makefile 并不是真正的选择......
编辑:请注意,我的无知假设这个解决方案是 gcc/++ 仅有的。然而,我对任何解决方案都很高兴,所以如果有一种方法滥用 ldconfig 或其他的某些属性,我并不反对它!
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 option....
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,只需执行
man gcc
即可。如果您愿意更改 Makefile,则需要-L
标志。还有一个类似于 ldconfig 的解决方案 - 使用 LIBRARY_PATH env。多变的。类似地,还有
CPLUS_INCLUDE_PATH
和C_INCLUDE_PATH
和CPATH
声明用于搜索头文件的目录列表。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 toldconfig
- to useLIBRARY_PATH
env. variable.Similarly, there's
CPLUS_INCLUDE_PATH
andC_INCLUDE_PATH
andCPATH
which are declaring a list of directories to search for header files.我认为除了修改 gcc/g++ 源代码并重新编译它之外,您不能使用
include
文件来执行此操作。最好的替代方案是向您的环境添加一个别名(如果使用 bash),例如:
或创建一个临时脚本。
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:or creating an ad-hoc script.