Good patterns for a C/C++ plugin-based system?

前端 未结 5 1564
-上瘾入骨i
-上瘾入骨i 2020-12-08 03:48

When developing a C/C++ (=2?) plugin based framework with shared objects/dynamic libraries that need to support live swapping what examples would be helpful to look at for i

5条回答
  •  死守一世寂寞
    2020-12-08 04:13

    If you want cross-platform library loading without having to develop for each platform's API individually, libltdl may help.

    Libtool provides a small library, called libltdl, that aims at hiding the various difficulties of dlopening libraries from programmers. It consists of a few headers and small C source files that can be distributed with applications that need dlopening functionality. On some platforms, whose dynamic linkers are too limited for a simple implementation of libltdl services, it requires GNU DLD, or it will only emulate dynamic linking with libtool's dlpreopening mechanism.

    libltdl supports currently the following dynamic linking mechanisms:

    • dlopen (Solaris, Linux and various BSD flavors)
    • shl_load (HP-UX)
    • LoadLibrary (Win16 and Win32)
    • load_add_on (BeOS)
    • NSAddImage or NSLinkModule (Darwin and Mac OS X)
    • GNU DLD (emulates dynamic linking for static libraries)
    • libtool's dlpreopen (see see Dlpreopening)

    Boost.Extension seems to only support Windows PE dlls, UNIX ELF shared objects, and Mac OS X Mach-O bundles. Well, that may be sufficient for you...

提交回复
热议问题