我不明白-Wl,-rpath -Wl, [英] I don't understand -Wl,-rpath -Wl,
问题描述
我的(错误)理解第一:如果我需要用,
分开选项,那意味着第二个 -Wl
不是另一种选择,因为它在,
之前,这意味着它是的参数。 -rpath
选项。
我不明白 -rpath
可以有一个 -Wl,。
参数!
在我看来,有意义的是:
pre $ -Wl,-rpath。
这应该使用当前目录参数调用-rpath链接器选项。
man gcc:
-Wl,option
将选项作为选项传递给
链接器。如果选项包含逗号,则
在
逗号分割为多个选项。您可以使用此语法将
传递给选项。对于
示例,-Wl,-Map,output.map
传递
-Map output.map
链接器。当使用GNU链接器
时,您还可以通过
`-Wl,-Map = output.map'获得
的相同效果。
man ld:
-rpath = dir
将目录添加到
运行时库搜索路径。这是在将ELF可执行文件
与共享对象关联时使用的
。将所有-rpath
参数连接起来并将
传递给运行时链接程序,该链接程序使用它们
在运行时定位共享对象。
当
定位显式共享对象所需的
共享对象时,也使用-rpath选项
包含在链接中;
gcc 的 -Wl,xxx
将逗号分隔的标记列表作为参数的空格分隔列表传递给链接器。所以
gcc -Wl,aaa,bbb,ccc
最终成为链接器调用
ld aaa bbb ccc
在你的情况下,你想说 ld -rpath。
,所以你把它传给gcc作为 -Wl,-rpath,。
或者,你可以指定 -Wl
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $请注意, 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屋!