1. Introduction
A question which frequently arises among Unix C++ programmers is
how to load C++ functions and classes dynamically using the
dlopen API.
In fact, that is not always simple and needs some
explanation. That's what this mini HOWTO does.
An average understanding of the C
and C++ programming language and of the
dlopen API is necessary to understand this
document.
This HOWTO's master location is http://www.isotton.com/howtos/C++-dlopen-mini-HOWTO/.
1.1. Copyright and License
This document, C++ dlopen mini HOWTO, is
copyrighted (c) 2002-2006 by Aaron Isotton.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU General Public License, Version
2, as published by the Free Software Foundation.
1.2. Disclaimer
No liability for the contents of this document can be
accepted. Use the concepts, examples and information at your
own risk. There may be errors and inaccuracies, that could be
damaging to your system. Proceed with caution, and although
this is highly unlikely, the author(s) do not take any
responsibility.
All copyrights are held by their by their respective owners,
unless specifically noted otherwise. Use of a term in this
document should not be regarded as affecting the validity of
any trademark or service mark. Naming of particular products
or brands should not be seen as endorsements.
1.3. Credits / Contributors
In this document, I have the pleasure of acknowledging (in
alphabetic order):
Joy Y Goodreau <joyg (at) us.ibm.com> for
her editing.
D. Stimitis <stimitis (at) idcomm.com>
for pointing out a few issues with the formatting and the
name mangling, as well as pointing out a few subtleties of
extern "C".
Many unnamed others pointing out errors or giving tips to
improve this howto. You know who you are!
1.4. Feedback
Feedback is most certainly welcome for this document. Send
your additions, comments and criticisms to the following email
address: <aaron@isotton.com>.
1.5. Terms Used in this Document
- dlopen API
The dlclose,
dlerror,
dlopen and
dlsym functions as described in the
dlopen(3) man page.
Notice that we use
"dlopen" to refer to
the individual dlopen
function, and
"dlopen API" to refer
to the entire API.