[CMake] CMake and portable dynamic library loading?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sat Sep 30 11:34:58 EDT 2006


On 2006-09-30 16:38+0200 Alexandre Courbot wrote:

> [...]How do you guys
> manage to dynamically load libraries on a cmake-based project?

Filipe Sousa has already answered about the CMake mechanics of making a
plug-in module to be dynamically loaded, but I think your question really
concerned how to dynamically load that plug-in from your code in a
cross-platform way.

That has concerned me as well for the PLplot project (which like yours has
recently been converted from autotools).  For now, we continue to call
libltdl routines from our code (for those who don't know, that is a small
part of the libtool package which provides a dynamic loading wrapper for all
Unix systems) to dynamically load our plug-ins.  Instead of building a
special copy of libltdl as part of PLplot like we did in the autotools days
we simply rely on external versions which now seem to be widely distributed,
and the result seems to work well on the Unix/Linux side of things.

However, libltdl does not solve the issue of how to dynamically load
plug-ins on windows systems.  (In our autotools days it built but did not
work properly for Cygwin and MinGW/MSYS, and I don't believe it has ever
been ported to bare windows.) So what do other projects do here for that
case?  Is there a good free library to call on the windows side?  I will
rely on Arjen, our PLplot windows expert, to interpret your ideas since I
don't have any windows experience myself.

(Strictly speaking, this is not a CMake topic, but I hope others here don't
mind me encouraging this topic on the list since I assume there are a lot of
projects represented here which have had to deal with the issue of what
libraries to call from their code to dynamically load plug-ins on both Unix
and windows.)

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list