My project links against a static library libA.a version 1.
This executable also links against another static library B. B is linked against A, but version 2.
Both symbol sets in version 1 and 2 of A are the same. Should this work if I know that nothing is shared that has anything to do with A between my project and B?
I managed to link it manually and it seems to work (maybe there are pitfalls I'm not aware of).
I can't make lib B a shared object, or use A as a shared object. Actually, I only know B is using A statically because I talked with the guy who wrote B.
I stand to be corrected, but it seems you can accomplish what you desire through a careful compilation process and judicious use of objcopy. The steps you should follow are:
objcopy --localize-symbols infile outfile
, and look here for details.I have never done this in practice, but all the building blocks appear to be in place. Step 4 is the hardest, because you have to identify all conflicting symbols -- probably manually.
About the "linking" part of your question, actually static libraries are not linked together. The linking step is only performed to obtain the final executable.
In fact you compiled your static library B using the headers of A (version 2). Then you linked your executable with both the B and A (version 1) libraries.
As far as the symbols are the same in both versions of A, there is no compiling issue. But you have to know that your executable actually only embed & use the version 1 of A.
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