6

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?

Mohit Deshpande
  • 53,877
  • 76
  • 193
  • 251

1 Answers1

11

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.

user502515
  • 4,346
  • 24
  • 20
  • So when ./configure && make is run, a static AND shared library is automatically produced? – Mohit Deshpande Nov 30 '10 at 01:09
  • 2
    Unless configure.ac sports a, say, `AC_DISABLE_STATIC`, it will build both by default. `AC_DISABLE_STATIC` may be countered by using `./configure --enable-static` for example. So what's in `configure.ac` really is a developer's suggestion to its users. – user502515 Nov 30 '10 at 21:39