I am building a shared library, and have a source tree structured like this:
Makefile.am
src/
Makefile.am
srcfile1.h
srcfile1.cpp
...
thirdpaty/
Makefile.am
lib1/
Makefile.am
lib1.h
lib1.cpp
...
lib2/
...
I use recursive Automake since some of the third party libraries are distributed with their own Automake files. src/Makefile.am
includes the usual libtool macros:
lib_LTLIBRARIES = libmylib.la
libmylib_la_SOURCES = scrfile1.h srcfile1.cpp ...
How do I link the main library to the third party ones? The Autotools manual leads me to believe that the third party libraries needs to be built as libtool convenience libraries, so I have the following in thirdparty/lib1/Makefile.am
:
noinst_LTLIBRARIES = libthirdpaty1.la
libthirdpaty1_la_SOURCES = lib1.cpp lib1.h
And add the following in src/Makefile.am
:
libmylib_la_LIBADD = $(top_buildir)/thirdparty/lib1/libthirdpaty1.la
My root Makefile.am holds the INCLUDES macro:
INCLUDES = -I$(top_builddir)/thirdparty
But building with this configuration gives me undefined symbol errors.
What is the correct way to structure this source code and link all the libraries together?