I have a C library in an archive file, clib.a
. I've written a C++ wrapper for it, cpp.o
, and would like to use this as a static library:
ar cTrvs cppwrap.a clib.a cpp.o
Code which links to this won't be able to use the stuff from clib.a
directly unless the correct header is included. However, if someone coincidentally creates an appropriate prototype -- e.g. void myCoincidentallyNamedGlobalFunction()
-- I'm concerned which definition of myCoincidentallyNamedGlobalFunction
will apply.
Since the symbols from clib.a
only need to be accessed in cpp.o
, and not anything linked to cppwrap.a
, is there a way to completely hide them so that there is no possible collision (so even including the clib header would fail)?
clib.o
something you're building yourself, or a monolithic binary you're handed by someone else that you want to wrap? – Russianstrip -N
orobjcopy -N
symbols you don't want exposed from your final distributed library. – Russiancpp.o
toclib.o
incppwrap.a
without exporting the symbols inclib.o
viacppwrap.a
?"clib.o
is actually an archive itself (clib.a
), if that makes any difference (I've edited the question to this effect) – Mistook