GCC选项的共享和-Wl共享区别 [英] Difference between -shared and -Wl,-shared of the GCC options
问题描述
我知道 -Wl,-shared
是 ld 的选项。我见过一些人像这样编译,
$ gcc -shared -Wl,-soname,libtest.so -o libtest .so * .o
有些人喜欢这样
$ gcc -Wl,-shared -Wl,-soname,libtest.so -o libtest.so * .o
因此,我想知道 -shared
和之间是否有区别。 -Wl,-shared
。
感谢。
-shared
传递给gcc或 -shared
到ld(通过 -Wl
)。将 -shared
传递给GCC可以在链接时启用或禁用其他标志。特别是,可能会涉及到不同的 crt *
文件。 要获得更多信息,grep for -shared
在GCC的 gcc / config /
目录和子目录中。
<为了给出一个具体的例子:在i386 FreeBSD上, gcc -shared
将链接到目标文件 crtendS.o code>,而没有
-shared
,它会链接到 crtend.o
中。因此, -shared
和 -Wl,-shared
并不等同。
I know -Wl,-shared
is a option of ld. I've seen some person compile like this,
$ gcc -shared -Wl,-soname,libtest.so -o libtest.so *.o
And some person like this
$ gcc -Wl,-shared -Wl,-soname,libtest.so -o libtest.so *.o
So, I want to know if there is some difference between -shared
and -Wl,-shared
.
Thanks.
There is a difference between passing -shared
to gcc or -shared
to ld (via -Wl
). Passing -shared
to GCC may enable or disable other flags at link time. In particular, different crt*
files might be involved.
To get more information, grep for -shared
in GCC's gcc/config/
directory and subdirectories.
Edit: To give a specific example: on i386 FreeBSD, gcc -shared
will link in object file crtendS.o
, while without -shared
, it will link in crtend.o
instead. Thus, -shared
and -Wl,-shared
are not equivalent.
这篇关于GCC选项的共享和-Wl共享区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!