Under automake, I have a third party static library and a static library I am building on top of it, which I want to use in executables statically linked with my library:
libthird.a, libmy.a, progs...
I am compiling libmy.a with (Makefile.am):
noinst_LIBRARIES = libmy.a
...sources...
libmy_a_LIBADD = libthird.a
When I compile and link a prog that calls libmy functions, it refuses to link, giving unresolved errors on all libthird symbols used by libmy.
As a try, I replaced
libmy_a_LIBADD = libthird.a
with
libmy_a_LIBADD = $(LIB_THIRD_OBJS)
i.e. explicitly the object files from which libthird.a is constructed, and it works. What am I doing wrong in the first case? libmy.a contains libthird.a in the first case (i.e. less libmy.a
shows object files and libthird.a)
As another try, I ran ar
on libmy.a, feeding it libthird.a, to produce libmyA.a, and that works as well: progs linked with libmyA.a have libthird symbols properly resolved.
Or is it not even possible, as (I think) explained here: Embed all external references when creating a static library ?
Why not:
prog_LDADD = libmy.a libthird.a
you should also omit:
libmy_a_LIBADD = libthird.a
in this case because libmy.a
is a static convenience library, so there's no real point to further linking it.