I have:
Where:
dlopen
to load D at runtime.Is it possible for D to use symbols defined in S when being run in A, without D being linked with S at its own compile-time? I.e. can D access symbols in the global namespace?
Other notes: I need D and A to both be able to call functions from S. I ideally don't want to alter S.
I've tried this, and I get (when a symbol from S is used in D):
dyld: lazy symbol binding failed: Symbol not found: __Z14myFunctioni
I presume this could either be:
extern "C"
and ruled this out).Perhaps I need to compile with different settings, or I have to always link all of S into D? Also would the situation changed if S became a dynamic library itself?
Thankyou
External references in the library are resolved using the libraries in that library's dependency list and any other libraries previously opened with the RTLD_GLOBAL flag. If the executable was linked with the flag "-rdynamic" (or, synonymously, "--export-dynamic"), then the global symbols in the executable will also be used to resolve references in a dynamically loaded library.