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).