What are the uses for dlopen vs standard dynamic linking?

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?

+2
source share
2 answers

So, are there other ways to use dlopen over standard dynamic linking / loading?

Typical use cases dlopenare

  • plugins
  • ( Intel)
  • API (GLEW OpenGL )
  • , ( , + )

... .

, , - , . Windows (google " DLL" ), Linux Implib.so.

+1

Windows, . , , language.dll. , . (1-, 2-, 3-), . , , .

, , . , , - .

, , . , , , C.

+1

Source: https://habr.com/ru/post/1693878/


All Articles