Say I have a library libfoo.so.1
, which depends (according to ldd
) on libbar.so.1
. However, libbar.so.1
is not available at the moment. My app needs to call a function in libfoo.so.1
which doesn't require libbar.so.1
at all.
Is there a way to load libfoo.so.1
, resolve the function symbol and then call it without having libbar.so.1
to satisfy the dependency? It's a case of "I know what I'm doing, just let me do it already". I tried the RTLD_LAZY flag, but it still tries to load the libbar.so.1
library before not loading the symbols.
EDIT
Here's the exact situation.
We have 3 players:
libbar.so.1
, a shared library located in a path not in LD_LIBRARY_PATH
or ldconfig
, and whose dependencies are all resolvedlibfoo.so.1
, a shared library located in a different directory than libbar
, but which depends on libbar
. At runtime, libfoo
will know where to locate libbar
.App
, a binary application which needs to load libfoo
at some point during runtime.App
doesn't know where to find libbar
, but knows that libfoo
knows. What I'm trying to accomplish is having an init function in libfoo
which would simply change App
's current working directory to where libbar
is located to finally resolve all the dependencies and make everyone happy.
libfoo
will eventually need to call stuff in libbar
, just not in this init function. I don't think creating a stub would work since the symbols would eventually need to resolve to the real functions.
Well, variables are still resolved even with RTLD_LAZY
, so in general you do need all the libraries to be linked. Seems like you should create a stub libbar.so.1
that has no functionality and can be found by the linker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With