3
votes

I have a program aa that depends on libbb which depends on libcc.

In libb's Makefile.am I have added

libbb_la_LIBADD = -lcc

In aa's Makefile I have added

aa_LDADD = -lbb

This works wonderful in the default case.

But I needed static linking, so I ran all the configures with --disable-shared.
Unfortunately when compiling aa I got:

libb_source.c: undefined reference to libcc_symbol

Any ideas what is missing?

Update: Don't think of specifying dependencies like this if you are crosscompiling and using a stagingdir.

1
If 'libbb' and 'libcc' are built with libtool, the LIBADD and LDADD variables should list libbb.la rather than -lbb. You might conditionally add -static to the AM_LDFLAGS variable.Brett Hale
@BrettHale Don't put answers in the comments, my friend! :)lmat - Reinstate Monica
But how else should I specify my dependencies if I'm crosscompiling and using a staging dir?Waldheinz

1 Answers

1
votes

Don't pass the link flag. Give it the name of the libtool archive and let automake work it out:

aa_LDADD = bb/libbb.la

In case you ever want to build Windows DLLs, you might also want to put -no-undefined in libbb_la_LDFLAGS.