In manpage of ld
(from binutils), there is this section about variations of -Bstatic
flag:
-Bstatic
-dn
-non_shared
-static
Do not link against shared libraries. This is only meaningful on platforms for which shared libraries are supported. The different variants of this option are for compatibility with various systems. You may use this option multiple times on the command line: it affects library searching for -l options which follow it. This option also implies--unresolved-symbols=report-all
. This option can be used with -shared. Doing so means that a shared library is being created but that all of the library's external references must be resolved by pulling in entries from static libraries.
My question is about the bolded sentence: exactly for which systems are these variants trying to be compatible? I have seen both -Bstatic
and -static
in various projects, but haven't seen anybody using the remaining two variants so far. For maximum compatibility (in terms of cross platform), which one is the best to use?
The -Bstatic
and -static
options are currently used, and are not the same:
-static
means: perform a completely static link (no shared libraries used at all).-Bstatic
means: for any -lfoo
that follows, use only archive version of the library.The other options: -dn
(added in 1993) and -non_shared
(added in 1994) are for compatibility with long-obsolete OSes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With