Linking two static libraries that have the same symbols

Started by
2 comments, last by swiftcoder 10 years, 6 months ago

I need to be able to use functionality from two static libraries which have been built under different build configurations. This is for backwards compatibility reasons. The problem is, during the linking process the library symbols conflict and the linker will just choose one over the other at random.

Is there anyway to get around this issue?

Thanks.

Advertisement

Short answer: no.

Longer answer: yes, if you're on a platform supporting weak symbols and one of the libraries has marked the symbol as weak and the other hasn't.

Final answer: this is an old, old problem. The language-level workaround is to properly namespace symbols. The linker-level workaround is either weak symbols or linker maps or both. The simple solution is to have access to the source and fix it.

Stephen M. Webb
Professional Free Software Developer

Yeah... there aren't a lot of options there. Do they have to be statically linked?

Last ditch hack, if Bregma's suggestions are not usable: statically link one of the libraries to a dynamically linked wrapper library which aliases the offending symbols.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement