I have this directory structure
prog/libA
prog/libB
In libA, I have a Makefile.am that looks like this:
noinst_LTLIBRARIES = libA.la
libA_la_SOURCES = ...
libA_la_LIBADD = ... $(LAPACK)
where LAPACK is my system's lapack installation. This works as expected. However, in libB I have this:
noinst_LTLIBRARIES = libB.la
bin_PROGRAMS = compLibB
libB_la_SOURCES = ...
compLibB_SOURCES = ...
libB_LIBADD = $(top_builddir)/libA/libA.la ...
compLibB_LDADD = libB.la
which does not work. The linking stage of compLibB complains about undefined references to LAPACK unless I change the last line to
compLibB_LDADD = libB.la $(LAPACK)
but that seems redundant. Haven't I already linked in $(LAPACK)
when I build the libA.la
convenience lib? It's unclean because now compLibB has to concern itself with the details of libA. Is there no way to link in the LAPACK libs at the libA build stage so that I don't have to re-specify it at the compLibB build stage?
Haven't I already linked in $(LAPACK) when I build the libA.la convenience lib?
As your linker has already told you, no. libA.la
being a convenience library is somewhat like a static library (a collection of object files).
It's unclean because now compLibB has to concern itself with the details of libA. Is there no way to link in the LAPACK libs at the libA build stage so that I don't have to re-specify it at the compLibB build stage?
You shouldn't need to specify the LAPACK libs when libA.la
is built because the final link hasn't happened yet. There's no way I know of accomplishing what you want without making libA
a shared library.