348 lines
5.7 KiB
HTML
348 lines
5.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Introduction</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="C++ dlopen mini HOWTO"
|
|
HREF="index.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="C++ dlopen mini HOWTO"
|
|
HREF="index.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="The Problem"
|
|
HREF="theproblem.html"></HEAD
|
|
><BODY
|
|
CLASS="section"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>C++ dlopen mini HOWTO</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="theproblem.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H1
|
|
CLASS="section"
|
|
><A
|
|
NAME="intro"
|
|
></A
|
|
>1. Introduction</H1
|
|
><P
|
|
> A question which frequently arises among Unix C++ programmers is
|
|
how to load C++ functions and classes dynamically using the
|
|
<TT
|
|
CLASS="function"
|
|
>dlopen</TT
|
|
> API.
|
|
</P
|
|
><P
|
|
>In fact, that is not always simple and needs some
|
|
explanation. That's what this mini HOWTO does.</P
|
|
><P
|
|
>An average understanding of the <SPAN
|
|
CLASS="systemitem"
|
|
>C</SPAN
|
|
>
|
|
and <SPAN
|
|
CLASS="systemitem"
|
|
>C++</SPAN
|
|
> programming language and of the
|
|
<TT
|
|
CLASS="function"
|
|
>dlopen</TT
|
|
> API is necessary to understand this
|
|
document.</P
|
|
><P
|
|
>This HOWTO's master location is <A
|
|
HREF="http://www.isotton.com/howtos/C++-dlopen-mini-HOWTO/"
|
|
TARGET="_top"
|
|
>http://www.isotton.com/howtos/C++-dlopen-mini-HOWTO/</A
|
|
>.</P
|
|
><DIV
|
|
CLASS="section"
|
|
><H2
|
|
CLASS="section"
|
|
><A
|
|
NAME="copyright"
|
|
></A
|
|
>1.1. Copyright and License</H2
|
|
><P
|
|
>This document, <EM
|
|
>C++ dlopen mini HOWTO</EM
|
|
>, is
|
|
copyrighted (c) 2002-2006 by <EM
|
|
>Aaron Isotton</EM
|
|
>.
|
|
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.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H2
|
|
CLASS="section"
|
|
><A
|
|
NAME="disclaimer"
|
|
></A
|
|
>1.2. Disclaimer</H2
|
|
><P
|
|
> 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.
|
|
</P
|
|
><P
|
|
> 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.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H2
|
|
CLASS="section"
|
|
><A
|
|
NAME="credits"
|
|
></A
|
|
>1.3. Credits / Contributors</H2
|
|
><P
|
|
> In this document, I have the pleasure of acknowledging (in
|
|
alphabetic order):
|
|
</P
|
|
><P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
>Joy Y Goodreau <TT
|
|
CLASS="email"
|
|
><<A
|
|
HREF="mailto:joyg (at) us.ibm.com"
|
|
>joyg (at) us.ibm.com</A
|
|
>></TT
|
|
> for
|
|
her editing.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>D. Stimitis <TT
|
|
CLASS="email"
|
|
><<A
|
|
HREF="mailto:stimitis (at) idcomm.com"
|
|
>stimitis (at) idcomm.com</A
|
|
>></TT
|
|
>
|
|
for pointing out a few issues with the formatting and the
|
|
name mangling, as well as pointing out a few subtleties of
|
|
<TT
|
|
CLASS="literal"
|
|
>extern "C"</TT
|
|
>.</P
|
|
><P
|
|
>Many unnamed others pointing out errors or giving tips to
|
|
improve this howto. You know who you are!</P
|
|
></LI
|
|
></UL
|
|
></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H2
|
|
CLASS="section"
|
|
><A
|
|
NAME="feedback"
|
|
></A
|
|
>1.4. Feedback</H2
|
|
><P
|
|
> Feedback is most certainly welcome for this document. Send
|
|
your additions, comments and criticisms to the following email
|
|
address: <TT
|
|
CLASS="email"
|
|
><<A
|
|
HREF="mailto:aaron@isotton.com"
|
|
>aaron@isotton.com</A
|
|
>></TT
|
|
>.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H2
|
|
CLASS="section"
|
|
><A
|
|
NAME="AEN91"
|
|
></A
|
|
>1.5. Terms Used in this Document</H2
|
|
><P
|
|
></P
|
|
><DIV
|
|
CLASS="variablelist"
|
|
><DL
|
|
><DT
|
|
><TT
|
|
CLASS="function"
|
|
>dlopen</TT
|
|
> API</DT
|
|
><DD
|
|
><P
|
|
>The <TT
|
|
CLASS="function"
|
|
>dlclose</TT
|
|
>,
|
|
<TT
|
|
CLASS="function"
|
|
>dlerror</TT
|
|
>,
|
|
<TT
|
|
CLASS="function"
|
|
>dlopen</TT
|
|
> and
|
|
<TT
|
|
CLASS="function"
|
|
>dlsym</TT
|
|
> functions as described in the
|
|
<TT
|
|
CLASS="literal"
|
|
>dlopen(3)</TT
|
|
> man page.</P
|
|
><P
|
|
>Notice that we use
|
|
<SPAN
|
|
CLASS="QUOTE"
|
|
>"<TT
|
|
CLASS="function"
|
|
>dlopen</TT
|
|
>"</SPAN
|
|
> to refer to
|
|
the individual <TT
|
|
CLASS="function"
|
|
>dlopen</TT
|
|
>
|
|
<EM
|
|
>function</EM
|
|
>, and
|
|
<SPAN
|
|
CLASS="QUOTE"
|
|
>"<TT
|
|
CLASS="function"
|
|
>dlopen</TT
|
|
> API"</SPAN
|
|
> to refer
|
|
to the <EM
|
|
>entire API</EM
|
|
>.</P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="theproblem.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>C++ dlopen mini HOWTO</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>The Problem</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |