禁止用gcc默认的库路径 [英] Inhibit default library paths with gcc
问题描述
有没有办法抑制用gcc默认的库路径搜索? -nostdinc
做到这一点的包括路径搜索,但 -nostdlib
,无论是由疏忽或设计,仅抑制 -lc -lgcc
等,但不是库搜索路径。
您应该能够的规范文件(虽然这些摆弄似乎是一个黑暗的艺术的东西给我...)。
如果你看一下输出 GCC -dumpspecs
的 link_command
规范是构建实际的一被调用命令。
link_libgcc
规范,这通常被定义(用于本地编译器至少)为其他规格的挖掘 * link_libgcc:
%D
是罪魁祸首:
%D
转储出每个GCC认为可能包含启动文件目录-l选项。如果目标支持一个multilib那么当前的multilib目录将是ppended每个这些路径$ P $。
块引用>
块引用>您可以通过创建一个文件来覆盖它(例如
my.specs
),它代替您所选择的路径:* link_libgcc:
-L /富/酒吧-L /等等/等等,然后通过
= -specs my.specs
到GCC
。Is there a way to inhibit the default library path search with gcc?
-nostdinc
does this for the include path search, but-nostdlib
, either by omission or by design, only inhibits the-lc -lgcc
etc. but not the library search paths.解决方案You should be able to do this with spec files (although fiddling with these seems like something of a dark art to me...).
If you look at the output of
gcc -dumpspecs
, thelink_command
spec is the one that builds the actual command that is invoked. Digging through some of the other specs it references, thelink_libgcc
spec, which is usually defined (for native compilers at least) as:*link_libgcc: %D
is the culprit:
%D
Dump out a -L option for each directory that GCC believes might contain startup files. If the target supports multilibs then the current multilib directory will be prepended to each of these paths.
You can override it by creating a file (e.g.
my.specs
) which substitutes paths of your choice:*link_libgcc: -L/foo/bar -L/blah/blah
and then passing
-specs=my.specs
togcc
.这篇关于禁止用gcc默认的库路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!