I'm trying to manipulate (or at least better understand) the symbol resolution order when loading dynamic libraries at runtime. In my example here I am using dlopen on a Linux OS.
I'm trying to get the dynamically loaded interpreter library "libmyint.so" to link with the function "message_from_library" in the shared object library "libmylib.so" and not with the "libmylib.a" that is linked into the application "myapp" which is what I currently have.
1 contains an archive of a simple example to understand this better. The following is the instructions on how to build the example and run it.
Instructions to build:
tar xzf code.tar.gz
mkdir app-build int-build lib-build
cd lib-build
cmake ../lib
make
cd ../int-build
cmake ../int
make
cd ../app-build
cmake ../app
make
./myapp
Actual output:
Call to statically linked interpreter function.
This message is from a static interpreter library object.
This message is from a static library object.
Call to dynamically loaded function in interpreter library.
This message is from a *shared* interpreter library object.
This message is from a static library object.
Desired output:
Call to statically linked interpreter function.
This message is from a static interpreter library object.
This message is from a static library object.
Call to dynamically loaded function in interpreter library.
This message is from a *shared* interpreter library object.
This message is from a *shared* library object.
I'm hoping someone can tell me how to get the desired output in this example.
Thanks.