为方便起见,我在下面添加了相关联机帮助页。
首先我的(错误)理解:如果我需要用 ,
分隔选项,那意味着第二个 -Wl
不是另一个选项,因为它在 之前>,
这意味着它是 -rpath
选项的参数。
我不明白 -rpath
怎么会有 -Wl,.
参数!
在我看来有意义的是:
-Wl,-rpath .
这应该使用当前目录参数调用 -rpath
链接器选项。
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'.
男人 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;
最佳答案
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,.
。
关于gcc - 我不明白 -Wl,-rpath -Wl,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41455979/