I have a shared library that tries to provide a standardized interface, basically a list of functions. Some of these functions are already provided by another shared library. So I could just write the additional functions and ask the user to link to both libraries, i.e. have him do this:
g++ foo.c -lmine -lother
In order to make things easier for the user, however, I don't want to do that. (Given the situation I'm in, this would be way more complicated than just adding a flag in some script.) I want the user to link only against my library and get the functions from the other library as well.
In Windows, I could use DLL forwarders and simply list the functions I want reexported. In MacOS, I could use the --reexport_library
linker option to make my library pretend to include the other one. If I didn't mind creating a full copy of the other library and had a static version, I could use the --whole-archive
on that to pull it into my library wholesale.
But is there any way in Linux to give the export table of my library an entry that says "this function is in that other library over there"?
Or alternatively, is there anything I can do to my library that makes it so that when it is given to the linker, the linker will say, "oh, I need to pull in that other library too"? The documentation of the --rpath-link
options suggests that this should just work, but it doesn't. libtool does this, of course, but libtool isn't an option.
What I could of course do is just fill my library with tiny stubs for these functions, but I'd rather not. That would be quite annoying what with having to do renaming in just the correct order so that the linker picks up the right version at the right time. But if there's really no other way, any help on proceeding with that would be appreciated too.
.so
was linked with-lsomething
, it will pull this library. It is widely used approach, e.g. libpng pulls libz, etc.. I don't understand the problem. – keltar Apr 1 '14 at 14:39something
, and the linker won't accept this if-lsomething
is not on the command line. – Sebastian Redl Apr 1 '14 at 16:15