Question

Let's say I've got a couple of .o files in a directory that get ar'ed into a static library:

ar cr libstuff.a a.o b.o

In another directory there are a couple of other .o files that need to be ar'ed in addition to the libstuff.a created above:

ar cr libother.a c.o d.o /path/to/stuff/libstuff.a

I thought that including libstuff.a would work there, however I get undefined symbols (that should be defined in libstuff.a) when I do that and then later try to link wtih libother.a. (using g++)

Is there a way to combine a .a into a static library like this or is this just not possible?

Was it helpful?

Solution

It you run 'ar t' on the new lib, you will find that it contains a copy of the old lib. Not useful.

You need to extract the input lib, add the new .o files, and then build a new lib with all the contents.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top