Problems with ld, libc, and "struct stat"
David Demelier
markand at malikania.fr
Wed Oct 16 11:44:33 UTC 2019
Le 16/10/2019 à 13:15, Jan Behrens a écrit :
> Do you know any link where I find a more detailed explanation about why
> I need to use "cc" instead of "ld" to create shared libraries? I assume
> that "cc" adds the necessary options to "ld" that are otherwise
> missing. But I don't see where this is documented.
Yes, many :-)
See output of clang -v when creating your shared library:
"/usr/bin/ld" --eh-frame-hdr -Bshareable --hash-style=both
--enable-new-dtags -o libfoo.so /usr/lib/crti.o /usr/lib/crtbeginS.o
-L/usr/lib test.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
--as-needed -lgcc_s --no-as-needed /usr/lib/crtendS.o /usr/lib/crtn.o
> When I search the man page for "cc" (clang - the Clang C, C++, and
> Objective-C compiler), I even do not find any "-shared" option at all.
-shared is a linker option, it's documented in gcc but basically clang
is usually retro-compatible with most of the GCC option. In fact,
-shared is just a shortcut to pass the appropriate shared arguments to
the underlying linker in that case -Bshareable (but may add additional
options as well).
Clang's manual page is not as full as gcc, that's true though.
Regards,
--
David
More information about the freebsd-questions
mailing list