I'm using dlopen to load a shared library at run time
dlopen("SharedLibarary1.so", RTLD_NOW | RTLD_GLOBAL);
In that shared object I refer to a const char* defined in another shared library "SharedLibarary2.so".
The Executable, and both the libraries are built using -rdynamic.
But I still get the run time error when using dlopen: "/usr/lib/SharedLibarary1.so: undefined symbol" and points to the mangled const char* has the undefined symbol.
Whith GDB "info share" I can see that the second library is not loaded at the point of the error.
How ever that problem goes away if I do a dlopen on the second library before I do on the first library.
Is there a better way to force the loader to load the second library for the unresolved symbol?
See Question&Answers more detail:os