According to the document, dlopen is used in conjunction with dlsymto load a library and get a pointer to a character.
But this is what the dynamic loader / linker does. Moreover, both methods are based on ld.so .
Actually, there seem to be two differences when using dlopen:
- The library can be conditionally loaded.
- The compiler does not know about the symbols (types, prototypes ...) that we use, and therefore does not check for possible errors. This, by the way, is a way to achieve introspection.
But, apparently, it does not motivate use dlopenover standard loading, with the exception of extreme examples:
- Conditional loading is actually not interesting from the point of view of optimizing memory size when a shared library is already in use by another program: loading an already used library does not increase the memory size.
- Avoiding compiler control is unsafe and a good way to write errors ... We also lack potential compiler optimizations.
So, are there any other use cases dlopencompared to standard dynamic linking / loading?
source
share