Reputation: 3
I’m having a problem with 2 static libraries in C having the same symbol naming. I have access to source code, but there are over 100 files with same symbol naming, and changing the source is not really an option. I’m using gcc compiler.
I’ve tried using objcopy —-prefix-symbols, but the issue is that it adds prefixes to standard libraries like memcopy. Adding objcopy —-prefix-symbols to standard libraries is becoming excessive.
I saw other suggestions of creating a wrapper library that protects the same named symbols. The issue I have is that when I try linking with only the wrapper libraries, I’m still getting linking errors looking for the same named symbol libraries. Is it even possible to use a wrapper library to protect the same named symbols?
Upvotes: 0
Views: 190
Reputation: 181429
I saw other suggestions of creating a wrapper library that protects the same named symbols. The issue I have is that when I try linking with only the wrapper libraries, I’m still getting linking errors looking for the same named symbol libraries. Is it even possible to use a wrapper library to protect the same named symbols?
A static wrapper library will not serve your purpose. Either such a library must incorporate the wrapped external objects (and therefore provide their identifiers as external symbols, too), or it must depend on those objects. Either way, the symbols you are hoping to hide must still be included in the link when you use such a library.
For a wrapper library to do what you are looking for, it must be a dynamically-linked shared library, incorporating the wrapped objects and built with a certain amount of extra attention to which symbols it exports.
Upvotes: 0