Create both static and shared library with GNU libtool?
Asked Answered
T

1

7

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?

Tavi answered 29/11, 2010 at 22:57 Comment(0)
D
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.

Dromedary answered 30/11, 2010 at 0:29 Comment(2)
So when ./configure && make is run, a static AND shared library is automatically produced?Tavi
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.Dromedary

© 2022 - 2024 — McMap. All rights reserved.