Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared library name collisions

I'm distributing a shared library (C++) and a python module that uses this library. I build a modified version of Bullet Physics Library (as a CMake subproject). I only use Bullet classes and functions in one file bullet_interface.cpp and all the Bullet stuff is hidden inside namespace { ... }.

The problem is that some other libraries require Bullet as a system dependency and link to the system version of Bullet. In fact, one of the dependencies of my library (libopenrave) exports Bullet symbols. (More specifically, it sometimes dynamically loads a plugin that exports Bullet symbols).

I'm wondering if there's a way to build my library so bullet_interface.cpp uses the correct Bullet functions, but then my library doesn't make any of the Bullet symbols visible. I can't use the system bullet because I had to make changes to the source code. One hacky solution would be to rename all of the Bullet functions and classes using a search and replace (almost all contain the string "bt"). Is there a better way?

like image 877
John Avatar asked Feb 11 '13 21:02

John


1 Answers

This is a bit of a roundabout way to accomplish what you want, but it beats a search-and-replace in bullet code.

You can try 'prefixing' symbols in the bullet library using the objcopy utility like this:

objcopy --prefix-symbols=old_ bullet.a

This should work with a dynamic library as well, but you'll have to try it. See this answer for details.

like image 136
George Skoptsov Avatar answered Oct 05 '22 10:10

George Skoptsov