ref: 2ad97d2058adb72528dd1cd118456a2864a9f5fa dlopen_test/README.md -rw-r--r-- 640 bytes
2ad97d20Tim Morgan Typo 2 years ago

This sample bit of code demonstrates how to use dlopen, 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.


  1. Compile the library:

    make lib
  2. Compile the program:

    make main
  3. Run the program, which will start a loop:

  4. Make a change to the library and recompile:

    make lib
  5. Witness the output change in the main program.


hello from lib_loaded
Loaded lib successfully
hello from lib_func