I am using an older system that has gcc 2.95.3, I have to link in two objects that although they have nothing to do with each other, they each have similarly named methods. I can’t rename either of them, but I would hope there is a way to build them as to not have the linker complain. The methods it is complaining about are each internally called by classes within the object. What can I do?
Share
If you have a complete GNU toolchain, you should be able to work around your problem using
objcopy, like this (if I’ve understood your problem correctly):Here are two very similar objects, “foo” and “bar”, both of which export a symbol called
clash– which is used internally, but doesn’t really need to be exported at all:and
And here’s the main code, which wants to use both:
Linking them together doesn’t work:
So, use
objcopyto change the visibility ofclashin one (or both, if you like!) of the objects:Now you can link successfully with the modified object – and the program behaves as it should: