我不明白 -Wl,-rpath -Wl, [英] I don't understand -Wl,-rpath -Wl,
问题描述
为方便起见,我在下面添加了相关的联机帮助页.
我的(错误)理解首先:如果我需要用 ,
分隔选项,那意味着第二个 -Wl
不是另一个选项,因为它在 之前>,
表示它是 -rpath
选项的参数.
我不明白 -rpath
怎么会有 -Wl,.
参数!
我认为有意义的是:
-Wl,-rpath .
这应该使用当前目录参数调用 -rpath
链接器选项.
man gcc:
<块引用>-Wl,选项
将选项作为选项传递给链接器.如果选项包含逗号,它被分成多个选项逗号.您可以使用此语法来将参数传递给选项.为了例如,-Wl,-Map,output.map
通过-Map output.map
到链接器.什么时候使用 GNU 链接器,您还可以获得与相同的效果`-Wl,-Map=output.map'.
男人:
<块引用>-rpath=dir
<块引用>
添加一个目录到运行时库搜索路径.这是链接 ELF 可执行文件时使用与共享对象.所有 -rpath参数被连接并传递到使用它们的运行时链接器在运行时定位共享对象.-rpath 选项也用于以下情况定位共享对象共享对象明确需要包含在链接中;
gcc 的 -Wl,xxx
选项将逗号分隔的标记列表作为空格传递- 链接器 的分隔参数列表.所以
gcc -Wl,aaa,bbb,ccc
最终成为链接器调用
ld aaa bbb ccc
在你的情况下,你想说ld -rpath .
",所以你把它作为 -Wl,-rpath,.
传递给 gcc 或者,你可以指定 -Wl
的重复实例:
gcc -Wl,aaa -Wl,bbb -Wl,ccc
注意aaa
和第二个-Wl
之间没有逗号.
或者,在您的情况下,-Wl,-rpath -Wl,.
.
For convenience I added the relevant manpages below.
My (mis)understanding first: If I need to separate options with ,
, that means that the second -Wl
is not another option because it comes before ,
which means it is an argument to the -rpath
option.
I don't understand how -rpath
can have a -Wl,.
argument!
What would make sense in my mind would be this:
-Wl,-rpath .
This should invoke -rpath
linker option with the current directory argument.
man gcc:
-Wl,option
Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. You can use this syntax to pass an argument to the option. For example,
-Wl,-Map,output.map
passes-Map output.map
to the linker. When using the GNU linker, you can also get the same effect with `-Wl,-Map=output.map'.
man ld:
-rpath=dir
Add a directory to the runtime library search path. This is used when linking an ELF executable with shared objects. All -rpath arguments are concatenated and passed to the runtime linker, which uses them to locate shared objects at runtime. The -rpath option is also used when locating shared objects which are needed by shared objects explicitly included in the link;
The -Wl,xxx
option for gcc passes a comma-separated list of tokens as a space-separated list of arguments to the linker. So
gcc -Wl,aaa,bbb,ccc
eventually becomes a linker call
ld aaa bbb ccc
In your case, you want to say "ld -rpath .
", so you pass this to gcc as -Wl,-rpath,.
Alternatively, you can specify repeat instances of -Wl
:
gcc -Wl,aaa -Wl,bbb -Wl,ccc
Note that there is no comma between aaa
and the second -Wl
.
Or, in your case, -Wl,-rpath -Wl,.
.
这篇关于我不明白 -Wl,-rpath -Wl,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!