This sample bit of code demonstrates how to use
dlsym, et al to dynamically load
a shared object file into a running process.
I've only tested this on Linux... I'm not sure if this will work on Mac or Windows without some tweaks.
Compile the library:
Compile the program:
Run the program, which will start a loop:
Make a change to the library and recompile:
Witness the output change in the main program.
hello from lib_loaded Loaded lib successfully hello from lib_func