1

I've created an autotools based package that generates a libxxx.a static library. What is the correct way to alter my configure.ac and Makefile.am files to create a libxxx.so shared library instead?

I did try following the instructions at:

How to create a shared library (.so) in an automake script?

I added LT_INIT to the end of my configure.ac, and replaced references to libtest_a with libtest_la in my src/Makefile.am

I then ran:

$ libtoolize && aclocal && autoconf && automake --add-missing && ./configure && make

which gets me a:

/bin/bash: --mode=compile: command not found

error message. What appears to be happening is that the build system has forgotten to use a compiler.

These are the original configure.ac

AC_INIT([libtest], [1.0])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
CXXFLAGS="$CXXFLAGS -std=c++0x"
AC_PROG_CXX
AM_PROG_AR
AC_PROG_RANLIB
AC_CONFIG_FILES([Makefile])
AC_OUTPUT([src/Makefile])

and src/Makefile.am files

AM_CPPFLAGS=-I../include
lib_LIBRARIES = libtest.a
libtest_a = -version-info 0:0:0
libtest_a_SOURCES = \

And here are the updated versions

AC_INIT([libtest], [1.0])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
CXXFLAGS="$CXXFLAGS -std=c++0x"
AC_PROG_CXX
AM_PROG_AR
AC_PROG_RANLIB
AC_CONFIG_FILES([Makefile])
AC_OUTPUT([src/Makefile])
LT_INIT

and

AM_CPPFLAGS=-I../include
lib_LTLIBRARIES = libtest.la
libtest_la = -version-info 0:0:0
libtest_la_SOURCES = \

respectively.

You'll notice the added LT_INIT in configure.ac and references to libtest.la instead of libtest.a, as well as the change to lib_LTLIBRARIES in src/Makefile.am

In both cases I've left out the value assigned to ..._SOURCES as irrelevant to this discussion (as well as rather long).

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
spierepf
  • 2,774
  • 2
  • 30
  • 52
  • possible duplicate of [How to create a shared library (.so) in an automake script?](http://stackoverflow.com/questions/8916425/how-to-create-a-shared-library-so-in-an-automake-script) – arved Sep 29 '15 at 08:11
  • Could you post `configure.ac` and `Makefile.am` files (perhaps omitting irrelevant sections for brevity). Are you in fact using `libtool`? What does the `./configure --enable-shared` produce? BTW, a well written package using autotools, can add the infrastructure with `autoreconf -fvi`. The [autotools mythbuster](https://autotools.io/index.html) is a practical and up to date. – Brett Hale Oct 01 '15 at 06:34
  • 1
    Don't put LT_INIT at the end. Put it nearer the beginning, but after AC_INIT. – Tom Tromey Oct 01 '15 at 16:13

0 Answers0