General answer: you cannot, but there are a few tricks you can do.
For example, objcopy from binutils has the ability to copy an object, but place a prefix on each character using - prefix characters . the prefix of things is often poor namespaces of people and is a βgoodβ way to avoid conflicts.
The usage is pretty simple, something like this:
objcopy --prefix-symbols "__mylib_" object.o new_object.o
NOTE: yes, it also works with .so files.
NOTE 2: this completely violates the C ++ name management, so try this only in the library with the C API. Since you are talking about adding a namespace where it does not exist, I assume that it is.
Evan teran
source share