0
votes

I have a Makefile.am with two noinst_LIBRARIES, and one of them needs to link with the other.

Adding it to the CFLAGS throws a compiler warning, but as far as I know, automake likes to freak out about using LDADD with libraries, since they are not complete programs.

How can I do this, assuming libb.a needs to pull in liba.a?

1
You don't link static libraries, they are added to your binary.Iharob Al Asimi
It's not clear to me what exactly you're trying to do, but note that you cannot link one static library to another. They're just a collection of object files, and there is no mechanism in static libraries to indicate that they depend on another library.nos
@nos true, however if there is dependency, i.e. if liba.a uses symbols from libb.a then when including the libraries in your binary you must be careful about the order in which you pass them. Which means that circular dependencies are not allowed.Iharob Al Asimi
@iharob Circular dependencies can be handled, but you must mention the libraries several times when linking the program that uses them, e.g. pass the flags -lA -lB -lAnos

1 Answers

1
votes

You can't do it. Actually, what you are trying to do doesn't really make sense. Static libraries are just archives containing object files and a table of contents. Put simply, you can think of a static library as a .zip containing .o files.

The linking phase only takes place when compiling a shared object or executable. When your program is linked against liba.a, you also need to specify -static -lb or similar and that's it.