I am picking up C in order to speed up some bits of a large python project. In order to add new functions to a continuously running python script, I have it occasionally check a .py file and integrate it's contents. I was wondering if there was a way of doing the equivalent in C. Is there a way to have it pick up the contents of a dynamic library on the fly?
Yes, you need to use dlopen
to access the library rather than linking at compile time, then dlsym
to access functions within it. To switch to a new library you'll need to dlclose
the handle and create a new one - wrapping this in a module to handle all of it is not a terribly difficult task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With