0

I have my main application and two libraries: foo and bar. foo uses bar in some methods, and it has it specified in the LDADD. My main application uses foo, and indirectly bar, so it has, in the Makefile, LDADD = foo.

In this case, if i don't also add bar library to the LDADD for my main application, i will get an compilation error.

Undefined reference; and it says that the .so files from foo require the .so files from bar.

I don't understand this. Once i compile ( non-static ) foo with LDADD = bar, why do i need it again when i'm compiling an app that is using foo ?

Cumatru
  • 695
  • 2
  • 12
  • 34
  • Possible duplicate of a known problem with [libtool on Ubuntu](http://stackoverflow.com/questions/11802727/libtool-doesnt-provide-library-dependencies-to-link). Are you using libtool on Ubuntu? – ldav1s Nov 07 '12 at 21:30

1 Answers1

1

You don't specify if foo and / or bar are libtool libraries built as part of the source tree. If they are, libtool should take take of the linking. i.e., since foo requires bar as part of a library:

libfoo_la_LIBADD = ../bar/libbar.la # in: foo/Makefile.am

and,

prog_LDADD = ../foo/libfoo.la # in: app/Makefile.am
Brett Hale
  • 21,653
  • 2
  • 61
  • 90