You can manually remove unneeded symbols on the final combined library:
$ objcopy -N foo cppwrap.a
(remove symbol)
Or, if you need the symbols but want to make sure that external users can't get to them:
$ objcopy -L bar cppwrap.a
(localize symbol)
Or, if a symbol in clib.a
must be visible by something in cpp.o
but you don't want it to be used by anyone else:
$ objcopy -W baz cppwrap.a
(weaken symbol)
In this case, collisions with symbols from other object files/libraries will defer to their usage, even though the symbol will still be visible. To obscure things further or to reduce chances of even a deferential collision, you can also use:
$ objcopy --redefine-sym old=new cppwrap.a
An anonymous namespace may help in some cases, but not if there's functionality that your wrapper needs but is trying to hide from external users.