glib-Dynamic-Loading-of-Modules.html   [plain text]


<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Dynamic Loading of Modules</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib-core.html" title="GLib Core Application Support"><link rel="previous" href="glib-Asynchronous-Queues.html" title="Asynchronous Queues"><link rel="next" href="glib-Memory-Allocation.html" title="Memory Allocation"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="refentry" href="glib-building.html" title="Compiling the GLib package"><link rel="refentry" href="glib-cross-compiling.html" title="Cross-compiling the GLib package"><link rel="refentry" href="glib-compiling.html" title="Compiling GLib Applications"><link rel="refentry" href="glib-running.html" title="Running GLib Applications"><link rel="refentry" href="glib-changes.html" title="Changes to GLib"><link rel="refentry" href="glib-resources.html" title="Mailing lists and bug reports"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="refentry" href="glib-Basic-Types.html" title="Basic Types"><link rel="refentry" href="glib-Limits-of-Basic-Types.html" title="Limits of Basic Types"><link rel="refentry" href="glib-Standard-Macros.html" title="Standard Macros"><link rel="refentry" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros"><link rel="refentry" href="glib-Byte-Order-Macros.html" title="Byte Order Macros"><link rel="refentry" href="glib-Numerical-Definitions.html" title="Numerical Definitions"><link rel="refentry" href="glib-Miscellaneous-Macros.html" title="Miscellaneous Macros"><link rel="refentry" href="glib-Atomic-Operations.html" title="Atomic Operations"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="refentry" href="glib-The-Main-Event-Loop.html" title="The Main Event Loop"><link rel="refentry" href="glib-Threads.html" title="
Threads"><link rel="refentry" href="glib-Thread-Pools.html" title="Thread Pools"><link rel="refentry" href="glib-Asynchronous-Queues.html" title="Asynchronous Queues"><link rel="refentry" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules"><link rel="refentry" href="glib-Memory-Allocation.html" title="Memory Allocation"><link rel="refentry" href="glib-IO-Channels.html" title="IO Channels"><link rel="refentry" href="glib-Error-Reporting.html" title="Error Reporting"><link rel="refentry" href="glib-Warnings-and-Assertions.html" title="Message Output and Debugging Functions"><link rel="refentry" href="glib-Message-Logging.html" title="Message Logging"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="refentry" href="glib-String-Utility-Functions.html" title="String Utility Functions"><link rel="refentry" href="glib-Character-Set-Conversion.html" title="Character Set Conversion"><link rel="refentry" href="glib-Unicode-Manipulation.html" title="Unicode Manipulation"><link rel="refentry" href="glib-I18N.html" title="Internationalization"><link rel="refentry" href="glib-Date-and-Time-Functions.html" title="Date and Time Functions"><link rel="refentry" href="glib-Random-Numbers.html" title="Random Numbers"><link rel="refentry" href="glib-Hook-Functions.html" title="Hook Functions"><link rel="refentry" href="glib-Miscellaneous-Utility-Functions.html" title="Miscellaneous Utility Functions"><link rel="refentry" href="glib-Lexical-Scanner.html" title="Lexical Scanner"><link rel="refentry" href="glib-Automatic-String-Completion.html" title="Automatic String Completion"><link rel="refentry" href="glib-Timers.html" title="Timers"><link rel="refentry" href="glib-Spawning-Processes.html" title="Spawning Processes"><link rel="refentry" href="glib-File-Utilities.html" title="File Utilities"><link rel="refentry" href="glib-Shell-related-Utilities.html" title="Shell-related Utilities"><link rel="refentry" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching"><link rel="refentry" href="glib-Simple-XML-Subset-Parser.html" title="Simple XML Subset Parser"><link rel="refentry" href="glib-Windows-Compatability-Functions.html" title="Windows Compatibility Functions"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="refentry" href="glib-Memory-Chunks.html" title="Memory Chunks"><link rel="refentry" href="glib-Doubly-Linked-Lists.html" title="Doubly-Linked Lists"><link rel="refentry" href="glib-Singly-Linked-Lists.html" title="Singly-Linked Lists"><link rel="refentry" href="glib-Double-ended-Queues.html" title="Double-ended Queues"><link rel="refentry" href="glib-Trash-Stacks.html" title="Trash Stacks"><link rel="refentry" href="glib-Hash-Tables.html" title="Hash Tables"><link rel="refentry" href="glib-Strings.html" title="Strings"><link rel="refentry" href="glib-String-Chunks.html" title="String Chunks"><link rel="refentry" href="glib-Arrays.html" title="Arrays"><link rel="refentry" href="glib-Pointer-Arrays.html" title="Pointer Arrays"><link rel="refentry" href="glib-Byte-Arrays.html" title="Byte Arrays"><link rel="refentry" href="glib-Balanced-Binary-Trees.html" title="Balanced Binary Trees"><link rel="refentry" href="glib-N-ary-Trees.html" title="N-ary Trees"><link rel="refentry" href="glib-Quarks.html" title="Quarks"><link rel="refentry" href="glib-Keyed-Data-Lists.html" title="Keyed Data Lists"><link rel="refentry" href="glib-Datasets.html" title="Datasets"><link rel="refentry" href="glib-Relations-and-Tuples.html" title="Relations and Tuples"><link rel="refentry" href="glib-Caches.html" title="Caches"><link rel="refentry" href="glib-Memory-Allocators.html" title="Memory Allocators"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="refentry" href="glib-gettextize.html" title="glib-gettextize"><link rel="index" href="ix01.html" title="Index"><link rel="section" href="glib-Dynamic-Loading-of-Modules.html#id3056963" title="Description"><link rel="section" href="glib-Dynamic-Loading-of-Modules.html#id3057146" title="Details"><meta name="generator" content="GTK-Doc V1.2 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-Asynchronous-Queues.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib-core.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-Memory-Allocation.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-Dynamic-Loading-of-Modules"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">Dynamic Loading of Modules</span></h2><p>Dynamic Loading of Modules &#8212; portable method for dynamically loading 'plug-ins'.</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">

#include &lt;gmodule.h&gt;


struct      <a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a>;
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Dynamic-Loading-of-Modules.html#g-module-supported">g_module_supported</a>              (void);
<a href="glib-Basic-Types.html#gchar">gchar</a>*      <a href="glib-Dynamic-Loading-of-Modules.html#g-module-build-path">g_module_build_path</a>             (const <a href="glib-Basic-Types.html#gchar">gchar</a> *directory,
                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *module_name);
<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a>*    <a href="glib-Dynamic-Loading-of-Modules.html#g-module-open">g_module_open</a>                   (const <a href="glib-Basic-Types.html#gchar">gchar</a> *file_name,
                                             <a href="glib-Dynamic-Loading-of-Modules.html#GModuleFlags">GModuleFlags</a> flags);
enum        <a href="glib-Dynamic-Loading-of-Modules.html#GModuleFlags">GModuleFlags</a>;
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Dynamic-Loading-of-Modules.html#g-module-symbol">g_module_symbol</a>                 (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module,
                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *symbol_name,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> *symbol);
G_CONST_RETURN <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Dynamic-Loading-of-Modules.html#g-module-name">g_module_name</a>         (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);
void        <a href="glib-Dynamic-Loading-of-Modules.html#g-module-make-resident">g_module_make_resident</a>          (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Dynamic-Loading-of-Modules.html#g-module-close">g_module_close</a>                  (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);
G_CONST_RETURN <a href="glib-Basic-Types.html#gchar">gchar</a>* <a href="glib-Dynamic-Loading-of-Modules.html#g-module-error">g_module_error</a>        (void);

const <a href="glib-Basic-Types.html#gchar">gchar</a>* (<a href="glib-Dynamic-Loading-of-Modules.html#GModuleCheckInit">*GModuleCheckInit</a>)            (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);
void        (<a href="glib-Dynamic-Loading-of-Modules.html#GModuleUnload">*GModuleUnload</a>)                (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);
#define     <a href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-SUFFIX-CAPS">G_MODULE_SUFFIX</a>
#define     <a href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-EXPORT-CAPS">G_MODULE_EXPORT</a>
#define     <a href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-IMPORT-CAPS">G_MODULE_IMPORT</a>
</pre></div><div class="refsect1" lang="en"><a name="id3056963"></a><h2>Description</h2><p>
These functions provide a portable way to dynamically load object files
(commonly known as 'plug-ins').
The current implementation supports all systems that provide
an implementation of <tt class="function"><tt class="function">dlopen()</tt></tt> (e.g. Linux/Sun), as well as HP-UX via its
<tt class="function"><tt class="function">shl_load()</tt></tt> mechanism, and Windows platforms via DLLs.
</p><p>
A program which wants to use these functions must be linked to the
libraries output by the command <span><b class="command">pkg-config --libs gmodule-2.0</b></span>.
</p><p>
To use them you must first determine whether dynamic loading
is supported on the platform by calling <a href="glib-Dynamic-Loading-of-Modules.html#g-module-supported"><tt class="function">g_module_supported()</tt></a>.
If it is, you can open a module with <a href="glib-Dynamic-Loading-of-Modules.html#g-module-open"><tt class="function">g_module_open()</tt></a>,
find the module's symbols (e.g. function names) with <a href="glib-Dynamic-Loading-of-Modules.html#g-module-symbol"><tt class="function">g_module_symbol()</tt></a>,
and later close the module with <a href="glib-Dynamic-Loading-of-Modules.html#g-module-close"><tt class="function">g_module_close()</tt></a>.
<a href="glib-Dynamic-Loading-of-Modules.html#g-module-name"><tt class="function">g_module_name()</tt></a> will return the file name of a currently opened module.
</p><p>
If any of the above functions fail, the error status can be found with
<a href="glib-Dynamic-Loading-of-Modules.html#g-module-error"><tt class="function">g_module_error()</tt></a>.
</p><p>
The <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a> implementation features reference counting for opened modules,
and supports hook functions within a module which are called when the
module is loaded and unloaded (see <a href="glib-Dynamic-Loading-of-Modules.html#GModuleCheckInit"><span class="type">GModuleCheckInit</span></a> and <a href="glib-Dynamic-Loading-of-Modules.html#GModuleUnload"><span class="type">GModuleUnload</span></a>).
</p><p>
If your module introduces static data to common subsystems in the running
program, e.g. through calling <tt class="literal">g_quark_from_static_string ("my-module-stuff")</tt>,
it must ensure that it is never unloaded, by calling <a href="glib-Dynamic-Loading-of-Modules.html#g-module-make-resident"><tt class="function">g_module_make_resident()</tt></a>.
</p></div><div class="refsect1" lang="en"><a name="id3057146"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3057152"></a><h3><a name="GModule"></a>struct GModule</h3><a class="indexterm" name="id3057163"></a><pre class="programlisting">struct GModule;</pre><p>
The <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a> struct is an opaque data structure to represent a
<a href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules">Dynamically-Loaded Module</a>.
It should only be accessed via the following functions.
</p></div><hr><div class="refsect2" lang="en"><a name="id3057197"></a><h3><a name="g-module-supported"></a>g_module_supported ()</h3><a class="indexterm" name="id3057209"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_module_supported              (void);</pre><p>
Checks if modules are supported on the current platform.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><tt class="literal">TRUE</tt> if modules are supported.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3057249"></a><h3><a name="g-module-build-path"></a>g_module_build_path ()</h3><a class="indexterm" name="id3057261"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>*      g_module_build_path             (const <a href="glib-Basic-Types.html#gchar">gchar</a> *directory,
                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *module_name);</pre><p>
A portable way to build the filename of a module. The platform-specific
prefix and suffix are added to the filename, if needed, and the result is
added to the directory, using the correct separator character.
</p><p>
The directory should specify the directory where the module can be found.
It can be <tt class="literal">NULL</tt> or an empty string to indicate that the module is in a standard
platform-specific directory, though this is not recommended since the
wrong module may be found.
</p><p>
For example, calling <a href="glib-Dynamic-Loading-of-Modules.html#g-module-build-path"><tt class="function">g_module_build_path()</tt></a> on a Linux system with a <i class="parameter"><tt>directory</tt></i>
of <tt class="filename">/lib</tt> and a <i class="parameter"><tt>module_name</tt></i> of "mylibrary" will return 
<tt class="filename">/lib/libmylibrary.so</tt>. On a Windows system, using 
<tt class="filename">\Windows</tt> as the directory it will return
<tt class="filename">\Windows\mylibrary.dll</tt>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>directory</tt></i> :</span></td><td>the directory where the module is. This can be <tt class="literal">NULL</tt> or the empty
string to indicate that the standard platform-specific directories will be 
used, though that is not recommended.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>module_name</tt></i> :</span></td><td>the name of the module.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the complete path of the module, including the standard library
prefix and suffix. This should be freed when no longer needed.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3057419"></a><h3><a name="g-module-open"></a>g_module_open ()</h3><a class="indexterm" name="id3057430"></a><pre class="programlisting"><a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a>*    g_module_open                   (const <a href="glib-Basic-Types.html#gchar">gchar</a> *file_name,
                                             <a href="glib-Dynamic-Loading-of-Modules.html#GModuleFlags">GModuleFlags</a> flags);</pre><p>
Opens a module. If the module has already been opened, its reference
count is incremented. 
</p><p>
First of all <a href="glib-Dynamic-Loading-of-Modules.html#g-module-open"><tt class="function">g_module_open()</tt></a> tries to open <i class="parameter"><tt>file_name</tt></i> as a module. If
that fails and <i class="parameter"><tt>file_name</tt></i> has the ".la"-suffix (and is a libtool archive) 
it tries to open the corresponding module. If that fails and it doesn't 
have the proper module suffix for the platform (<a href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-SUFFIX-CAPS"><span class="type">G_MODULE_SUFFIX</span></a>), this 
suffix will be appended and the corresponding module will be opended. If 
that fails and <i class="parameter"><tt>file_name</tt></i> doesn't have the ".la"-suffix, this suffix is 
appended and <a href="glib-Dynamic-Loading-of-Modules.html#g-module-open"><tt class="function">g_module_open()</tt></a> tries to open the corresponding module. If 
eventually that fails as well, <tt class="literal">NULL</tt> is returned.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>file_name</tt></i> :</span></td><td>the name of the file containing the module.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>flags</tt></i> :</span></td><td>the flags used for opening the module. This can be the logical
OR of any of the <a href="glib-Dynamic-Loading-of-Modules.html#GModuleFlags"><span class="type">GModuleFlags</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>a <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a> on success, or <tt class="literal">NULL</tt> on failure.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3057599"></a><h3><a name="GModuleFlags"></a>enum GModuleFlags</h3><a class="indexterm" name="id3057609"></a><pre class="programlisting">typedef enum
{
  G_MODULE_BIND_LAZY	= 1 &lt;&lt; 0,
  G_MODULE_BIND_LOCAL	= 1 &lt;&lt; 1,
  G_MODULE_BIND_MASK	= 0x03
} GModuleFlags;
</pre><p>
Flags passed to <a href="glib-Dynamic-Loading-of-Modules.html#g-module-open"><tt class="function">g_module_open()</tt></a>. Note that these flags are
not supported on all platforms.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><tt class="literal">G_MODULE_BIND_LAZY</tt></span></td><td>specifies that symbols are only resolved when needed.
  The default action is to bind all symbols when the module is loaded.
</td></tr><tr><td><span class="term"><tt class="literal">G_MODULE_BIND_LOCAL</tt></span></td><td>specifies that symbols in the module should
  not be added to the global name space.  The default action on most
  platforms is to place symbols in the module in the global name space,
  which may cause conflicts with existing symbols.
</td></tr><tr><td><span class="term"><tt class="literal">G_MODULE_BIND_MASK</tt></span></td><td>mask for all flags.

</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3057695"></a><h3><a name="g-module-symbol"></a>g_module_symbol ()</h3><a class="indexterm" name="id3057706"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_module_symbol                 (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module,
                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *symbol_name,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> *symbol);</pre><p>
Gets a symbol pointer from a module.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>module</tt></i> :</span></td><td>a <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>symbol_name</tt></i> :</span></td><td>the name of the symbol to find.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>symbol</tt></i> :</span></td><td>returns the pointer to the symbol value.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><tt class="literal">TRUE</tt> on success.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3057819"></a><h3><a name="g-module-name"></a>g_module_name ()</h3><a class="indexterm" name="id3057830"></a><pre class="programlisting">G_CONST_RETURN <a href="glib-Basic-Types.html#gchar">gchar</a>* g_module_name         (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);</pre><p>
Gets the filename from a <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>module</tt></i> :</span></td><td>a <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the filename of the module, or "main" if the module is the main
program itself.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3057904"></a><h3><a name="g-module-make-resident"></a>g_module_make_resident ()</h3><a class="indexterm" name="id3057916"></a><pre class="programlisting">void        g_module_make_resident          (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);</pre><p>
Ensures that a module will never be unloaded.
Any future <a href="glib-Dynamic-Loading-of-Modules.html#g-module-close"><tt class="function">g_module_close()</tt></a> calls on the module will be ignored.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>module</tt></i> :</span></td><td>a <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a> to make permanently resident.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3057983"></a><h3><a name="g-module-close"></a>g_module_close ()</h3><a class="indexterm" name="id3057994"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_module_close                  (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);</pre><p>
Closes a module.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>module</tt></i> :</span></td><td>a <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a> to close.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><tt class="literal">TRUE</tt> on success.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3058063"></a><h3><a name="g-module-error"></a>g_module_error ()</h3><a class="indexterm" name="id3058074"></a><pre class="programlisting">G_CONST_RETURN <a href="glib-Basic-Types.html#gchar">gchar</a>* g_module_error        (void);</pre><p>
Gets a string describing the last module error.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>a string describing the last module error.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3058112"></a><h3><a name="GModuleCheckInit"></a>GModuleCheckInit ()</h3><a class="indexterm" name="id3058124"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* (*GModuleCheckInit)            (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);</pre><p>
Specifies the type of the module initialization function.
If a module contains a function named <tt class="function">g_module_check_init()</tt> it is called
automatically when the module is loaded. It is passed the <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a> structure
and should return <tt class="literal">NULL</tt> on success or a string describing the initialization
error.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>module</tt></i> :</span></td><td>the <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a> corresponding to the module which has just been loaded.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><tt class="literal">NULL</tt> on success, or a string describing the initialization error.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3058225"></a><h3><a name="GModuleUnload"></a>GModuleUnload ()</h3><a class="indexterm" name="id3058236"></a><pre class="programlisting">void        (*GModuleUnload)                (<a href="glib-Dynamic-Loading-of-Modules.html#GModule">GModule</a> *module);</pre><p>
Specifies the type of the module function called when it is unloaded.
If a module contains a function named <tt class="function">g_module_unload()</tt> it is called
automatically when the module is unloaded.
It is passed the <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a> structure.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>module</tt></i> :</span></td><td>the <a href="glib-Dynamic-Loading-of-Modules.html#GModule"><span class="type">GModule</span></a> about to be unloaded.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3058314"></a><h3><a name="G-MODULE-SUFFIX-CAPS"></a>G_MODULE_SUFFIX</h3><a class="indexterm" name="id3058326"></a><pre class="programlisting">#define G_MODULE_SUFFIX "so"
</pre><p>
Expands to the proper shared library suffix for the current platform
without the leading dot. For the most Unices and Linux this is "so",
for some HP-UX versions this is "sl" and for Windows this is "dll".
</p></div><hr><div class="refsect2" lang="en"><a name="id3058345"></a><h3><a name="G-MODULE-EXPORT-CAPS"></a>G_MODULE_EXPORT</h3><a class="indexterm" name="id3058356"></a><pre class="programlisting">#define     G_MODULE_EXPORT</pre><p>
Used to declare functions exported by modules.
</p></div><hr><div class="refsect2" lang="en"><a name="id3058372"></a><h3><a name="G-MODULE-IMPORT-CAPS"></a>G_MODULE_IMPORT</h3><a class="indexterm" name="id3058384"></a><pre class="programlisting">#define	G_MODULE_IMPORT		extern
</pre><p>
Used to declare functions imported from modules.
</p></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-Asynchronous-Queues.html"><b>&lt;&lt; Asynchronous Queues</b></a></td><td align="right"><a accesskey="n" href="glib-Memory-Allocation.html"><b>Memory Allocation &gt;&gt;</b></a></td></tr></table></body></html>