0

I've a library file which was built using g++ version 2.96. The source code of the lib is not available and also there is no support from the original developer.

I want to link it with my application using the latest g++ version (say 4.x). As I understand the name mangling scheme has changed since gcc veriosn 3.3 onwards. That's why the new linker does not recognize the symbols in the old lib file.

I've done some research on the net and studied tools like objcopy, objdump, c++filt and nm etc and tried to find and demangle the symbols in the lib file manually, but to no avail.

So, is there a way (or a tool) to transform my old binary lib file to the new name mangling scheme so I can link it using newer compilers?

1 Answers1

0

No, this is not possible.

You can't just translate the mangled names, there are lots of other things that are not compatible between g++ 2.96 and g++ 4.x, including the layout of objects, the exception-handling mechanism, the standard library implementation, how virtual functions work etc.

Either get the source code for the old lib, or build everything with g++ 2.96, or replace the old lib with new code that has the same behaviour.

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521
  • Ok what about translating to slightly older version such as gcc 3.4? Is that also not possible? – Suleman Khalid May 27 '15 at 12:30
  • 3.4 is compatible with 4.x anyway, but even for 3.3 or other versions it's not possible to convert between incompatible ABIs. No. Impossible. Give up. – Jonathan Wakely May 27 '15 at 12:31
  • Thanks for your prompt replies. Just curious, would your answer be the same if it were not a C++ lib and instead just a plain C library. Would it still not be possible? – Suleman Khalid May 27 '15 at 16:57
  • C doesn't have exception-handling, base classes, virtual functions etc. so its ABI is much simpler. The C ABI is fixed by the platform and doesn't differ between compiler versions. – Jonathan Wakely May 28 '15 at 09:48