I'm writing a static lib that needs to handle XML. I want it to include everything that is necessary out of the box but I don't know how to make other static libs link to it, namely libxml2.
I pass the -c flag to gcc to generate .o that ar then uses to create the lib. What magic flag combination must I pass to have my static lib swallow libxml2?
libraries don't just swallow other libraries. there's two solutions to do what you want that i can think of.
Sadly, what's been most effective for me is to extract all the .os from the static library and then include them with your .os to make a single .a
So you could look at the contents of libxml2.a with ar t libxml2.a
Let's say for simplicity that it only contained: xml2a.o and xml2b.o
You want to combine those with your mine.o to make mine.a
You'll need to first do ar x libxml2.a to get out xml2a.o and xml2b.o
Then do ar cr mine.a mine.o xml2a.o xml2b.o
A simple explanation of the most widely used ar commands, though I've probably summarized what you'd get from it here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With