4 ms·
I am a perpetual newbie when it comes to things like this. What's the advantage of dlopen()-ing instead of dynamic linking?
by nerdponx 3y ago
I am a perpetual newbie when it comes to things like this. What's the advantage of dlopen()-ing instead of dynamic linking?
- tux3 3y agoFaster program start, and potentially making it a soft-dependency instead of a hard dep (or letting you fallback on something else if it's not there)
- d3m0t3p 3y agoYou can load libs at runtime with dl-open, for exemple if you need a feature you can load the corresponding lib. While with dynamic linking you'd load everything when the process is launched slowing the launch
- sgtnoodle 3y agoA more obscure use would be for loading multiple instances of a singleton library. This is especially helpful in something like a unit test suite, where you want each test case to start in a cleanly initialized state. If the code under test has a bunch of globally initialized variables, reloading the library at runtime is one of only a few possible ways of doing it.