libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: libltdl examples


From: Bob Friesenhahn
Subject: RE: libltdl examples
Date: Fri, 30 Dec 2005 14:32:53 -0600 (CST)

On Fri, 30 Dec 2005, Eric Lemings wrote:
Do any of these use C++ as their primary language?  And
does libltdl
work the same even if the package is configured with
--disable-shared?

The main issues with C++ are platform limitations with C++ static
initialization and the usefulness of exporting symbols that
need to be
resolved as C language symbols so they are not subject to mangling.

What I'm really looking for is a good example of a package written in
C++ that uses libltdl to load libraries at run-time.  How they do it,
problems to watch out for, etc.

You use the term "libraries". Do you intend to load a "library" so it extends the available global symbol space, or do you intend to load a "module" and use libltdl to obtain the address of functions at run-time?

From the application's perspective, there is no difference if the
application is written in C or C++. From a module's perspective, there can be some differences.

To get around the problems you mention, I'm declaring exported symbols
in my C++ code with C linkage and I don't have any variables (so far)
in my dlopened libraries that require static initialization.

Normal variables should be correctly initialized regardless of C/C++. C++ static objects are a bit "iffy" on some platforms, and the framework to support C++ exceptions may also need to be initialized. If there is a problem with C++ exceptions, then the program may crash as soon as one is thrown.

Using libltdl is pretty easy. You can provide libltdl with a module search path and use a bare module name, or you can compute your own path and provide a full path (path to .la file is preferred) to libltdl. Rather than using libldtl to resolve many symbols, it may be easiest if a module interface is invoked to register its methods/objects with the program. In order to support graceful shutdown/unload you would want to have a module method which is invoked so that the module can release any resources it has (or unbind itself from the rest of the application) before the module is unloaded using libltdl.

Bob
======================================
Bob Friesenhahn
address@hidden, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]