Search code examples
shared-librariesstatic-librariesautotoolslibtool

Create both static and shared library with GNU libtool?


I am using the GNU autotools (including automake!) for my project. I would like to know if I could create a static and a shared library using libtool? Or would the declarations be separate? Would this:

LT_INIT(shared static)

work?


Solution

  • Nothing besides LT_INIT is needed, it defaults to building both static and shared libraries. If you like, you can again explicitly state the defaults (but it is sort of redundant)

    LT_INIT
    AC_ENABLE_SHARED
    AC_ENABLE_STATIC

    edit: manual says LT_INIT([shared]) and LT_INIT([static]) (combined to LT_INIT([shared static]) shall also work. Also manual's more precise wording on what's default when LT_INIT is given: this macro turns on shared libraries if they are available, and also enables static libraries if they don't conflict with the shared libraries.