1 @node LD Version Scripts
2 @section LD Version Scripts
4 The @code{lib-symbol-versions} module can be used to add shared
5 library versioning support. Currently, only GNU LD and the Solaris
8 Version scripts provides information that can be used by GNU/Linux
9 distribution packaging tools. For example, Debian has a tool
10 @code{dpkg-shlibdeps} that can determine the minimal required version
11 of each dependency (by looking at the symbol list) and stuff the
12 information into the Debian specific packaging files.
14 For more information and other uses of version scripts, see Ulrich
15 Drepper's paper @url{https://www.akkadia.org/drepper/dsohowto.pdf}
17 You use the module by importing it to your library, and then add the
18 following lines to the @code{Makefile.am} that builds the library:
21 if HAVE_LD_VERSION_SCRIPT
22 libfoo_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libfoo.map
26 The version script file format is documented in the GNU LD manual, but
27 a small example would be:
32 libfoo_init; libfoo_doit; libfoo_done;
39 If you target platforms that do not support linker scripts (i.e., all
40 platforms that doesn't use GNU LD) you may want to consider a more
41 portable but less powerful alternative: libtool
42 @code{-export-symbols}. It will hide internal symbols from your
43 library, but will not add ELF versioning symbols. Your usage would
44 then be something like:
47 if HAVE_LD_VERSION_SCRIPT
48 libfoo_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libfoo.map
50 libfoo_la_LDFLAGS += -export-symbols $(srcdir)/libfoo.sym
54 See the Libtool manual for the file syntax, but a small example would
63 To avoid the need for a @code{*.sym} file if your symbols are easily
64 expressed using a regular expression, you may use
65 @code{-export-symbols-regex}:
68 if HAVE_LD_VERSION_SCRIPT
69 libfoo_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libfoo.map
71 libfoo_la_LDFLAGS += -export-symbols-regex '^libfoo_.*'
75 For more discussions about symbol visibility, rather than shared
76 library versioning, see the @code{visibility} module
77 (@pxref{Exported Symbols of Shared Libraries}).