summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2010-06-05 17:24:39 +0200
committerAndreas Baumann <abaumann@yahoo.com>2010-06-05 17:24:39 +0200
commit451eeb4245cd4d0b5168ad86dbb8b0bb5125d958 (patch)
treed2908ce57e3ede85e31da0320df40952df7e674d /docs
parentd7744a6847b2b16d4c89fc66e2cedc02cae927f8 (diff)
downloadwolfbones-451eeb4245cd4d0b5168ad86dbb8b0bb5125d958.tar.gz
wolfbones-451eeb4245cd4d0b5168ad86dbb8b0bb5125d958.tar.bz2
added proper library building, added documentation
Diffstat (limited to 'docs')
-rw-r--r--docs/libraries/LibraryArchives-StaticAndDynamic.html1853
1 files changed, 1853 insertions, 0 deletions
diff --git a/docs/libraries/LibraryArchives-StaticAndDynamic.html b/docs/libraries/LibraryArchives-StaticAndDynamic.html
new file mode 100644
index 0000000..e458e4f
--- /dev/null
+++ b/docs/libraries/LibraryArchives-StaticAndDynamic.html
@@ -0,0 +1,1853 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>Linux Tutorial - Static, Shared Dynamic and Loadable Linux Libraries</title>
+ <link rel="stylesheet" href="yolinux.css" type="text/css" />
+ <link rel=”canonical” href=”http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html" />
+ <meta name="keywords" content="static libraries,shared objects,dynamic libraries,loadable libraries,linux,development,ar, ranlib" />
+ <meta name="description" content="YoLinux Tutorials: Static, Shared Dynamic and Loadable Linux Libraries. Linux Information Portal includes informative tutorials and links to many Linux sites. The YoLinux portal covers topics from desktop to servers and from developers to users" />
+ <meta name="author" content="Greg Ippolito" />
+</head>
+
+<body bgcolor="#cccccc">
+<p>
+</p>
+<table cellpadding="4" width="100%">
+ <tbody>
+ <tr>
+ <td valign="top">
+ <a href="http://www.yolinux.com/"><img src="images/YoLinux_Tutorial_logo.png" alt="Yolinux.com Tutorial" border="none" /></a>
+ </td>
+ <td valign="top">
+ <h1>Static, Shared Dynamic and Loadable Linux Libraries</h1>
+ <p>
+This tutorial discusses the philosophy behind libraries and the creation and
+use of C/C++ library "shared components" and "plug-ins".
+The various technologies and methodologies used and insight to their appropriate application, is also discussed.
+In this tutorial, all libraries are created using the GNU Linux compiler.
+ </p>
+ <p>
+ </p>
+ <div align="right">
+<!-- ValueClick Media 468x60 and 728x90 Banner CODE for yo-linux.com -->
+<script language="javascript" src="http://media.fastclick.net/w/get.media?sid=51962&m=1&tp=5&d=j&t=s"></script>
+<noscript><a href="http://media.fastclick.net/w/click.here?sid=51962&m=1&c=1" target="_top">
+<img src="http://media.fastclick.net/w/get.media?sid=51962&m=1&tp=5&d=s&c=1"
+width=728 height=90 border=1></a></noscript>
+<!-- ValueClick Media 468x60 and 728x90 Banner CODE for yo-linux.com -->
+
+ </div>
+
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>
+</p>
+<!-- Menu bar -->
+<table bgcolor="#000000" width="100%">
+<tbody>
+<tr bgcolor="#000000">
+<td colspan="3">
+<form method="post" action="http://www.yolinux.com/cgi-bin/htsearch">
+<input type="hidden" name="method" value="all" />
+<input type="hidden" name="format" value="long" />
+<input type="hidden" name="sort" value="score" />
+<input type="hidden" name="config" value="htdig-yolinux" />
+<input type="hidden" name="restrict" value="" />
+<input type="hidden" name="exclude" value="" />
+<input type="text" size="20" maxlength="80" name="words">
+<input type="submit" value="Search">
+</td>
+<td align="right">
+<font color="#f7bc33" size="-1">
+<b>
+&nbsp;|&nbsp;
+<a href="/" class="menubar" title="YoLinux Home Page">Home Page</a>&nbsp;|&nbsp;
+<a href="/TUTORIALS/" class="menubar" title="YoLinux Web Site Tutorials Index">Linux Tutorials</a>&nbsp;|&nbsp;
+<a href="/YoLinux-Terms.html" class="menubar" title="YoLinux.com terms of use" rel="nofollow">Terms</a>&nbsp;|&nbsp;
+<a href="/privacy.html" class="menubar" title="YoLinux.com privacy policy" rel="nofollow">Privacy Policy</a>&nbsp;|&nbsp;
+<a href="/YoLinux-Advertising.html" class="menubar" title="Advertising rates for YoLinux.com">Advertising</a>&nbsp;|&nbsp;
+<a href="/YoLinuxEmailForm.html" class="menubar" title="Send us an email" rel="nofollow">Contact</a> &nbsp;|&nbsp;
+</b>
+</font>
+</form>
+</td>
+</tr>
+</tbody>
+</table>
+<!-- End of menu bar -->
+
+<table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#cccccc">
+ <td bgcolor="#c0c0c0" valign="top" width="160">
+ <p>
+ <font size="-1">
+ <b>Related YoLinux Tutorials:</b>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="LinuxTutorialC++.html">C++ Info, links</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="LinuxTutorialC++StringClass.html">C++ String Class</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="LinuxTutorialC++STL.html">C++ STL vector, list</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="ForkExecProcesses.html">Fork and exec</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="Sockets.html">Sockets programming</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="LinuxTutorialXemacs.html">Emacs and C/C++</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="LinuxTutorialAdvanced_vi.html">Advanced VI</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="LinuxTutorialC++CGI.html">CGI in C++</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="ClearcaseCommands.html">Clearcase Commands</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="MicrosoftVisualC++Tips.html">MS/Visual C++ Practices</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="C++MemoryCorruptionAndMemoryLeaks.html">C++ Memory corruption and leaks</a>
+ </font></p>
+ <p>
+ <font size="-1">&deg;<a href="index.html">YoLinux Tutorials Index</a>
+ </font>
+ </p>
+
+<hr />
+<p>
+<!-- BEGIN RICH-MEDIA CODE -->
+<script type="text/javascript"><!--
+google_ad_client = "pub-8567479315106986";
+/* 160x600, created 10/19/09 */
+google_ad_slot = "2598351238";
+google_ad_width = 160;
+google_ad_height = 600;
+//-->
+</script>
+<script type="text/javascript"
+src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+</p>
+<hr />
+<p>
+<!-- Ad links -->
+<script type="text/javascript"><!--
+google_ad_client = "pub-8567479315106986";
+google_ad_width = 160;
+google_ad_height = 90;
+google_ad_format = "160x90_0ads_al_s";
+google_ad_channel ="";
+google_color_border = "FFFFFF";
+google_color_bg = "C0C0C0";
+google_color_link = "0000FF";
+google_color_text = "000000";
+google_color_url = "008000";
+//-->
+</script>
+<script type="text/javascript"
+ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+</p>
+<!-- END CODE -->
+<hr />
+<p>
+<a href="http://yolinux.tradepub.com/">Free Information Technology Magazines and Document Downloads<br /><img src="images/TradePubMagazines.gif" border="0" alt="TradePub link image" /></a>
+</p>
+<hr />
+
+ <p>
+ <a href="http://yolinux.tradepub.com/?pt=cat&amp;page=Infosoft">Free Information Technology <b>Software and Development</b> Magazine Subscriptions and Document Downloads</a>
+ </p>
+ <p>
+ </p>
+ <hr />
+ <p>
+ </p>
+ </td>
+
+ <td>
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Why libraries are used: </big></b></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p> This methodology, also known as "shared components" or
+"archive libraries", groups together multiple compiled object code
+files into a single file known as a library. Typically C functions/C++
+classes and methods which can be shared by more than one application
+are broken out of the application's source code, compiled and bundled
+into a library.
+The C standard libraries and C++ STL are examples of shared components
+which can be linked with your code. The benefit is that each and every
+object file need not be stated when linking because the developer can
+reference the individual library. This simplifies the
+multiple use and sharing of software components between applications.
+It also allows application vendors a way to simply release an API to
+interface with an application.
+Components which are large can be created for dynamic use, thus the
+library remain separate from the executable reducing it's size and thus
+disk space used.
+The library components are then called by various applications for use
+when needed. </p>
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Linux Library Types: </big></b></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>
+There are two Linux C/C++ library types which can be created:
+ </p>
+ <ol>
+ <li>Static libraries (.a): Library of object code which is linked with, and becomes part of the application.
+ </li>
+ <li>Dynamically linked shared object libraries (.so): There is only one form of this library but it can be used in two ways.
+ <ol>
+ <li>Dynamically linked at run time but statically aware. The
+libraries must be available during compile/link phase. The shared
+objects are not included into the executable component but are tied to
+the execution. </li>
+ <li>Dynamically loaded/unloaded and linked during execution
+(i.e. browser plug-in) using the dynamic linking loader system
+functions. </li>
+ </ol>
+ </li>
+ </ol>
+
+ <p>
+ </p>
+ <h4>Library naming conventions:</h4>
+Libraries are typically names with the prefix "lib". This is true for
+all the C standard libraries. When linking, the command line reference
+to the library will not contain the library prefix or suffix.
+ <p>
+Thus the following link command: <tt>gcc src-file.c -lm -lpthread</tt>
+ <br />
+The libraries referenced in this example for inclusion during linking
+are the math library and the thread library. They are found in
+ <tt>/usr/lib/lib<b>m</b>.a</tt> and <tt>/usr/lib/lib<b>pthread</b>.a</tt>.
+ </p>
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Static Libraries: (.a)</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>
+How to generate a library:
+ </p>
+ <ul>
+
+ <li>Compile: <tt>cc -Wall -c ctest1.c ctest2.c</tt>
+ <br />
+
+ Compiler options:
+
+ <ul>
+
+ <li>-Wall: include warnings. See man page for warnings specified.
+ </li>
+ </ul>
+
+ </li>
+ <li>Create library "libctest.a": <tt>ar -cvq libctest.a ctest1.o ctest2.o</tt>
+ </li>
+ <li>List files in library: <tt>ar -t libctest.a</tt>
+ </li>
+ <li>Linking with the library:
+
+ <ul>
+
+ <li><tt>cc -o <i>executable-name</i> prog.c libctest.a</tt>
+ </li>
+ <li><tt>cc -o <i>executable-name</i> prog.c -L/path/to/library-directory -lctest</tt>
+ </li>
+ </ul>
+
+ </li>
+ <li>Example files:
+
+ <ul>
+
+ <li>ctest1.c
+
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+
+ <pre>void ctest1(int *i)<br />{<br /> *i=5;<br />}<br /> </pre>
+
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </li>
+ <li>ctest2.c
+
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+
+ <pre>void ctest2(int *i)<br />{<br /> *i=100;<br />}<br /> </pre>
+
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </li>
+ <li>prog.c
+
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+
+ <pre>#include &lt;stdio.h&gt;<br />void ctest1(int *);<br />void ctest2(int *);<br /><br />int main()<br />{<br /> int x;<br /> ctest1(&amp;x);<br /> printf("Valx=%d\n",x);<br /><br /> return 0;<br />}<br /> </pre>
+
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </li>
+ </ul>
+
+ </li>
+ </ul>
+
+Historical note:
+After creating the library it was once necessary to run the command: <tt>ranlib ctest.a</tt>.
+This created a symbol table within the archive. Ranlib is now embedded into the "ar"
+command.
+ <p>
+Note for MS/Windows developers: The Linux/Unix ".a" library is conceptually
+the same as the Visual C++ static ".lib" libraries.
+ </p>
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Dynamically Linked "Shared Object" Libraries: (.so)</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>
+How to generate a shared object: (Dynamically linked object library file.)
+Note that this is a two step process.
+ </p>
+ <ol>
+
+ <li>Create object code
+ </li>
+ <li>Create library
+ </li>
+ <li>Optional: create default version using a symbolic link.
+ </li>
+ </ol>
+
+ <b>Library creation example:</b>
+
+ <dl>
+ <dd>
+
+ <pre> gcc -Wall -fPIC -c *.c
+ gcc -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0 *.o
+ mv libctest.so.1.0 /opt/lib
+ ln -sf /opt/lib/libctest.so.1.0 /opt/lib/libctest.so
+ ln -sf /opt/lib/libctest.so.1.0 /opt/lib/libctest.so.1
+ </pre>
+
+ This creates the library <tt>libctest.so.1.0</tt> and symbolic links to it.
+
+ <p>
+ Compiler options:
+ </p>
+ <ul>
+ <li><tt>-Wall</tt>: include warnings. See man page for warnings specified.
+ </li>
+ <li><tt>-fPIC</tt>: Compiler directive to output position independent code, a characteristic required by shared libraries. Also see "-fpic".
+ </li>
+ <li><tt>-shared</tt>: Produce a shared object which can then be linked with other objects to form an executable.
+ </li>
+ <li><tt>-W1</tt>: Pass options to linker.
+ <br />
+In this example the options to be passed on to the linker are:
+ "<tt>-soname libctest.so.1</tt>".
+ The name passed with the "-o" option is passed to <tt>gcc</tt>.
+ </li>
+ <li>Option <tt>-o</tt>: Output of operation. In this case the name of the shared object to be output will be "<tt>libctest.so.1.0</tt>"
+ </li>
+ </ul>
+
+
+ <p>
+ Library Links:
+ </p>
+ <ul>
+
+ <li>The link to <tt>/opt/lib/libctest.so</tt> allows the naming convention for the compile flag <tt>-lctest</tt> to work.
+ </li>
+ <li>The link to <tt>/opt/lib/libctest.so.1</tt> allows the run time binding to work. See dependency below.
+ </li>
+ </ul>
+
+ </dd>
+ </dl>
+
+
+ <p>
+ <b>Compile main program and link with shared object library:</b>
+ </p>
+ <dl>
+ <dd>
+Compiling for runtime linking with a dynamically linked <tt>libctest.so.1.0</tt>:
+ <pre> gcc -Wall -I<i>/path/to/include-files</i> -L<i>/path/to/libraries</i> prog.c -lctest -o prog
+Use:
+ gcc -Wall -L/opt/lib prog.c -lctest -o prog
+ </pre>
+
+Where the name of the library is <tt>libctest.so</tt>. (This is why you must create the symbolic links or you will get the error "/usr/bin/ld: cannot find -lctest".)
+ <br />
+
+The libraries will NOT be included in the executable but will be dynamically linked during runtime execution.
+ </dd>
+ </dl>
+
+ <p>
+ <b>List Dependencies:</b>
+ </p>
+ <p>
+The shared library dependencies of the executable can be listed with the
+command: <tt><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ldd"><b>ldd</b></a> <i>name-of-executable</i></tt>
+ </p>
+ <p>
+ </p>
+ <dl>
+ <dd>
+ Example: <tt>ldd prog</tt>
+
+ <pre> libctest.so.1 =&gt; /opt/lib/libctest.so.1 (0x00002aaaaaaac000)
+ libc.so.6 =&gt; /lib64/tls/libc.so.6 (0x0000003aa4e00000)
+ /lib64/ld-linux-x86-64.so.2 (0x0000003aa4c00000)
+ </pre>
+
+ </dd>
+ </dl>
+
+ <p>
+ <b>Run Program:</b>
+ </p>
+ <ul>
+
+ <li>Set path: <tt>export LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH</tt>
+ </li>
+ <li>Run: <tt>prog</tt>
+ </li>
+ </ul>
+
+ <p>
+ <b>Man Pages:</b>
+ </p>
+ <ul>
+
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=gcc">gcc</a> - GNU C compiler
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ld">ld</a> - The GNU Linker
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ldd">ldd</a> - List dependencies
+ </li>
+ </ul>
+
+ <p>
+ <b>Links:</b>
+ </p>
+ <ul>
+
+ <li><a href="http://www.tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html">LDP: Shared libraries</a>
+ </li>
+ </ul>
+
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td><b><big>Library Path:</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>In order for an executable to find the required libraries to
+link with during run time, one must configure the system so that the
+libraries can be found.
+Methods available: (Do at least one of the following)
+</p>
+ <ol>
+
+ <li>Add library directories to be included during dynamic linking to the file
+ <tt>/etc/ld.so.conf</tt>
+ <p>
+Sample: <tt>/etc/ld.so.conf</tt>
+ </p>
+ <dl>
+ <dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>/usr/X11R6/lib
+/usr/lib
+...
+..
+/usr/lib/sane
+/usr/lib/mysql
+/opt/lib
+ </pre>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </dd>
+ </dl>
+Add the library path to this file and then execute the command (as root)
+ <tt>ldconfig</tt> to configure the linker run-time bindings.
+ <br />
+
+You can use the "<b>-f <i>file-name</i></b>" flag to reference another
+configuration file if you are developing for different environments.
+ <br />
+
+See man page for command
+ <a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ldconfig">ldconfig</a>.
+ <p>
+ <b>OR</b>
+ </p>
+ <p>
+ </p>
+ </li>
+ <li>Add specified directory to library cache: (as root)
+ <br />
+ <tt>ldconfig -n <i>/opt/lib</i></tt>
+ <br />
+ Where <tt>/opt/lib</tt> is the directory containing your library <tt>libctest.so</tt>
+ <br />
+(When developing and just adding your current directory: <tt>ldconfig -n .</tt> Link with -L.)
+ <p>This will NOT permanently configure the system to include this directory. The information will be lost upon system reboot.
+ </p>
+ <p>
+ <b>OR</b>
+ </p>
+ <p>
+ </p>
+ </li>
+ <li>Specify the environment variable <tt>LD_LIBRARY_PATH</tt> to point to the directory paths containing the shared object library.
+This will specify to the run time loader that the library paths will be used during execution to resolve dependencies.
+ <br />
+(Linux/Solaris: <tt>LD_LIBRARY_PATH</tt>, SGI: <tt>LD_LIBRARYN32_PATH</tt>, AIX: <tt>LIBPATH</tt>, Mac OS X: <tt>DYLD_LIBRARY_PATH</tt>, HP-UX: <tt>SHLIB_PATH</tt>)
+ <p>
+Example (bash shell): <tt>export LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH</tt>
+or add to your <tt>~/.bashrc</tt> file:
+ </p>
+ <dl>
+ <dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>...
+if [ -d /opt/lib ];
+then
+ LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH
+fi
+
+...
+
+export LD_LIBRARY_PATH
+ </pre>
+
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </dd>
+ </dl>
+
+ <br />
+
+This instructs the run time loader to look in the path described by the environment variable <tt>LD_LIBRARY_PATH</tt>, to resolve shared libraries. This will include the path <tt>/opt/lib</tt>.
+ </li>
+ </ol>
+
+ <p>
+Library paths used should conform to the "<a href="http://www.linuxbase.org/">Linux Standard Base</a>" directory structure.
+ </p>
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td><b><big>Library Info:</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>
+The command "nm" lists symbols contained in the object file or shared library.
+ </p>
+ <p>
+Use the command <tt>nm -D libctest.so.1.0</tt>
+ <br />
+(or <tt>nm --dynamic libctest.so.1.0</tt>)
+ </p>
+ <dl>
+ <dd>
+ <pre>0000000000100988 A __bss_start
+000000000000068c T ctest1
+00000000000006a0 T ctest2
+ w __cxa_finalize
+00000000001007b0 A _DYNAMIC
+0000000000100988 A _edata
+0000000000100990 A _end
+00000000000006f8 T _fini
+0000000000100958 A _GLOBAL_OFFSET_TABLE_
+ w __gmon_start__
+00000000000005b0 T _init
+ w _Jv_RegisterClasses
+ </pre>
+
+ </dd>
+ </dl>
+
+ <a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=nm">Man page for nm</a>
+ <dl>
+ <dd>
+ <table border="1">
+
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <th>Symbol Type</th>
+ <th>Description</th>
+ </tr>
+
+ <tr>
+ <td>A</td>
+ <td>The symbol's value is absolute, and will not be changed by further linking.</td>
+ </tr>
+
+ <tr>
+ <td>B</td>
+ <td>Un-initialized data section</td>
+ </tr>
+
+ <tr>
+ <td>D</td>
+ <td>Initialized data section</td>
+ </tr>
+
+ <tr>
+ <td>T</td>
+ <td>Normal code section</td>
+ </tr>
+
+ <tr>
+ <td>U</td>
+ <td>Undefined symbol used but not defined. Dependency on another library.</td>
+ </tr>
+
+ <tr>
+ <td>W</td>
+ <td>Doubly defined symbol. If found, allow definition in another library to resolve dependency.</td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ </dd>
+ </dl>
+
+ <p>
+Also see:
+ <a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=objdump">objdump</a> man page
+ </p>
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Library Versions:</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>Library versions should be specified for shared objects if the
+function interfaces are expected to change (C++ public/protected class
+definitions), more or fewer functions are included in the library, the
+function prototype changes (return data type (int, const int, ...) or
+argument list changes) or data type changes (object definitions: class
+data members, inheritance, virtual functions, ...). </p>
+ <p>The library version can be specified when the shared object
+library is created.
+If the library is expected to be updated, then a library version should
+be specified. This is especially important for shared object libraries
+which are dynamically linked. This also avoids the Microsoft "DLL hell"
+problem of conflicting libraries where a system upgrade which changes a
+standard library breaks an older application expecting an older version
+of the the shared object function. </p>
+ <p>Versioning occurs with the GNU C/C++ libraries as well. This
+often make binaries compiled with one version of the GNU tools
+incompatible with binaries compiled with other versions unless those
+versions also reside on the system. Multiple versions of the same
+library can reside on the same system due to versioning. The version of
+the library is included in the symbol name so the linker knows which
+version to link with.
+</p>
+ <p>
+One can look at the symbol version used: <tt>nm csub1.o</tt>
+ </p>
+ <dl>
+ <dd>
+ <pre>00000000 T ctest1
+<br /></pre>
+
+No version is specified in object code by default.
+ </dd>
+ </dl>
+
+ <a href="http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_mono/ld.html">ld and object file layout</a>
+ <p>
+There is one GNU C/C++ compiler flag that explicitly deals with symbol versioning.
+Specify the version script to use at compile time with the flag: <tt>--version-script=<i>your-version-script-file</i></tt>
+ <br />
+Note: This is only useful when creating shared libraries. It is assumed
+that the programmer knows which libraries to link with when static
+linking. Runtime linking allows opportunity for library
+incompatibility.
+</p>
+ <p>
+GNU/Linux, see examples of version scripts here:
+ <tt>sysdeps/unix/sysv/linux/Versions</tt>
+ </p>
+ <p>
+Some symbols may also get version strings from assembler code which
+appears in glibc headers files. Look at <tt>include/libc-symbols.h</tt>.
+ </p>
+ <p>
+Example: <tt> nm /lib/libc.so.6 | more</tt>
+ </p>
+ <dl>
+ <dd>
+ <pre>00000000 A GCC_3.0
+00000000 A GLIBC_2.0
+00000000 A GLIBC_2.1
+00000000 A GLIBC_2.1.1
+00000000 A GLIBC_2.1.2
+00000000 A GLIBC_2.1.3
+00000000 A GLIBC_2.2
+00000000 A GLIBC_2.2.1
+00000000 A GLIBC_2.2.2
+00000000 A GLIBC_2.2.3
+00000000 A GLIBC_2.2.4
+...
+..
+ </pre>
+
+Note the use of a version script.
+ <p>
+Library referencing a versioned library: <tt>nm /lib/libutil-2.2.5.so</tt>
+ </p>
+ <pre>..
+...
+ U strcpy@@GLIBC_2.0
+ U strncmp@@GLIBC_2.0
+ U strncpy@@GLIBC_2.0
+...
+..
+ </pre>
+
+ </dd>
+ </dl>
+
+ <p>
+ <b>Links:</b>
+ </p>
+ <ul>
+
+ <li><a href="http://gcc.gnu.org/ml/gcc-help/2004-03/msg00265.html">Symbol versioning</a>
+ </li>
+ <li><a href="http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_mono/ld.html#SEC25">GNU.org: ld version scripts</a>
+ </li>
+ </ul>
+
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Dynamic loading and un-loading of shared libraries using libdl:</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>
+These libraries are dynamically loaded / unloaded and linked during execution.
+Usefull for creating a "plug-in" architecture.
+ </p>
+ <p>
+Prototype include file for the library: <tt>ctest.h</tt>
+ </p>
+ <dl>
+ <dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>#ifndef CTEST_H
+#define CTEST_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void ctest1(int *);
+void ctest2(int *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+ </pre>
+
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+Use the notation <tt>extern "C"</tt> so the libraries can be used with
+C and C++. This statement prevents the C++ from name mangling and thus
+creating "unresolved symbols" when linking.
+</dd>
+ </dl>
+
+ <p>
+Load and unload the library <tt>libctest.so</tt> (created above), dynamically:
+ </p>
+ <dl>
+ <dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>
+#include &lt;stdio.h&gt;
+#include &lt;dlfcn.h&gt;
+#include "ctest.h"
+
+int main(int argc, char **argv)
+{
+ void *lib_handle;
+ double (*fn)(int *);
+ int x;
+ char *error;
+
+ lib_handle = dlopen("/opt/lib/libctest.so", RTLD_LAZY);
+ if (!lib_handle)
+ {
+ fprintf(stderr, "%s\n", dlerror());
+ exit(1);
+ }
+
+ fn = dlsym(lib_handle, "ctest1");
+ if ((error = dlerror()) != NULL)
+ {
+ fprintf(stderr, "%s\n", error);
+ exit(1);
+ }
+
+ (*fn)(&amp;x);
+ printf("Valx=%d\n",x);
+
+ dlclose(lib_handle);
+ return 0;
+}
+ </pre>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </dd>
+ </dl>
+
+ <p>
+ <tt>gcc -rdynamic -o progdl progdl.c -ldl</tt>
+ </p>
+ <p>
+Explanation:
+ </p>
+ <ul>
+
+ <li><tt>dlopen("/opt/lib/libctest.so", RTLD_LAZY);</tt>
+ <br />
+Open shared library named "<tt>libctest.so</tt>".
+ <br />
+The second argument indicates the binding. See include file <tt>dlfcn.h</tt>.
+ <br />
+Returns NULL if it fails.
+ <br />
+Options:
+
+ <ul>
+
+ <li>RTLD_LAZY: If specified, Linux is not concerned about unresolved symbols until they are referenced.
+ </li>
+ <li>RTLD_NOW: All unresolved symbols resolved when <tt>dlopen()</tt> is called.
+ </li>
+ <li>RTLD_GLOBAL: Make symbol libraries visible.
+ </li>
+ </ul>
+
+ </li>
+ <li><tt>dlsym(lib_handle, "ctest1");</tt>
+ <br />
+Returns address to the function which has been loaded with the shared library..
+ <br />
+Returns NULL if it fails.
+ <br />
+Note: When using C++ functions, first use <tt>nm</tt> to find the
+ "mangled" symbol name or use the <tt>extern "C"</tt> construct to avoid
+ name mangling.
+ <br />
+i.e. <tt>extern "C" void <i>function-name</i>();</tt>
+ </li>
+ </ul>
+<p>
+<b>Object code location:</b> Object code archive libraries can be located with either the executable or the loadable library.
+Object code routines used by both should not be duplicated in each.
+This is especially true for code which use static variables such as singleton classes.
+A static variable is global and thus can only be represented once.
+Including it twice will provide unexpected results.
+The programmer can specify that specific object code be linked with the executable by using linker commands which are passed on by the compiler.
+</p>
+<p>
+Use the "-Wl" gcc/g++ compiler flag to pass command line arguments on to the GNU "ld" linker.
+</p>
+<p>Example makefile statement: <tt>g++ -rdynamic -o appexe $(OBJ) $(LINKFLAGS) -Wl,--whole-archive -L{AA_libs} -laa -Wl,--no-whole-archive $(LIBS)</tt>
+</p>
+<ul>
+<li>--whole-archive: This linker directive specifies that the libraries listed following this directive (in this case <tt>AA_libs</tt>) shall be included in the resulting output even though there may not be any calls requiring its presence. This option is used to specify libraries which the loadable libraries will require at run time.</li>
+<li>-no-whole-archive: This needs to be specified whether you list additional object files or not. The gcc/g++ compiler will add its own list of archive libraries and you would not want all the object code in the archive library linked in if not needed. It toggles the behavior back to normal for the rest of the archive libraries.</li>
+</ul>
+ <p>
+ <b>Man pages:</b>
+ </p>
+ <ul>
+
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=dlopen">dlopen()</a> - gain access to an executable object file
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=dlclose">dclose()</a> - close a dlopen object
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=dlsym">dlsym()</a> - obtain the address of a symbol from a dlopen object
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=dlvsym">dlvsym()</a> - Programming interface to dynamic linking loader.
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=dlerror">dlerror()</a> - get diagnostic information
+ </li>
+ </ul>
+
+ <p>
+ <b>Links:</b>
+ </p>
+ <ul>
+
+ <li><a href="http://www.samspublishing.com/articles/article.asp?p=22435&amp;rl=1">Shared Libraries-Dynamic Loading and Unloading</a>
+ </li>
+ <li><a href="http://developer.gnome.org/doc/API/glib/glib-dynamic-loading-of-modules.html">GNOME Glib dynamic loading of modules</a> - cross platform API for dynamically loading "plug-ins".
+ </li>
+ </ul>
+
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>C++ class objects and dynamic loading:</big></b></td>
+ </tr>
+ </tbody>
+ </table>
+ <p>
+<b>C++ and name mangling:</b>
+ </p>
+ <p>
+When running the above "C" examples with the "C++" compiler one will quickly find that "C++" function names get mangled and thus will not work unless the function definitions are protected with <tt>extern "C"{}</tt>.
+ <dl>
+ <dd>
+Note that the following are not equivalent:
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td width="50%">
+ <pre>
+extern "C"
+{
+ int functionx();
+}
+ </pre>
+ </td>
+ <td valign="top">
+ <pre>
+extern "C" int functionx();
+ </pre>
+ </td>
+ </tr></tbody></table>
+ <p>
+ </p>
+ The following are equivalent:
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td width="50%">
+ <pre>
+extern "C"
+{
+ extern int functionx();
+}
+ </pre>
+ </td>
+ <td valign="top">
+ <pre>
+extern "C" int functionx();
+ </pre>
+ </td>
+ </tr></tbody></table>
+ </dd></dl>
+ </p>
+ <p>
+<b>Dynamic loading of C++ classes:</b>
+ </p>
+ <p>
+The dynamic library loading routines enable the programmer to load "C" functions.
+In C++ we would like to load class member functions. In fact the entire class may be in the library and we may want to load and have access to the entire object and all of its member functions.
+Do this by passing a "C" class factory function which instantiates the class.
+ </p>
+ The class ".h" file:
+ <dl><dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>
+class Abc {
+
+...
+...
+
+};
+
+// Class factory "C" functions
+
+typedef Abc* create_t;
+typedef void destroy_t(Abc*);
+ </pre>
+ </td></tr></tbody></table>
+ </dd></dl>
+ <p>
+ </p>
+ The class ".cpp" file:
+ <dl><dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>
+Abc::Abc()
+{
+ ...
+}
+
+extern "C"
+{
+ // These two "C" functions manage the creation and destruction of the class Abc
+
+ Abc* create()
+ {
+ return new Abc;
+ }
+
+ void destroy(Abc* p)
+ {
+ delete p; // Can use a base class or derived class pointer here
+ }
+}
+ </pre>
+ </td></tr></tbody></table>
+This file is the source to the library.
+The "C" functions to instantiate (create) and destroy a class defined in the dynamically loaded library where "Abc" is the C++ class.
+ </dd></dl>
+ <p>
+ </p>
+ Main executable which calls the loadable libraries:
+ <dl><dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>
+// load the symbols
+ create_t* create_abc = (create_t*) dlsym(lib_handle, "create");
+
+...
+...
+
+ destroy_t* destroy_abc = (destroy_t*) dlsym(lib_handle, "destroy");
+
+...
+...
+ </pre>
+ </td></tr></tbody></table>
+ </dd></dl>
+<p>
+</p>
+<b>Pitfalls:</b>
+ <ul>
+ <li>The new/delete of the C++ class should both be provided by the
+ executable or the library but not split. This is so that there is
+ no surprise if one overloads new/delete in one or the other.
+ </li>
+ </ul>
+<p>
+</p>
+<b>Links:</b>
+ <ul>
+ <li><a href="http://www.linuxjournal.com/article/3687">LinuxJournal.com: Dynamic Class Loading for C++ on Linux</a>
+ </li>
+ <li><a href="http://www.isotton.com/howtos/C++-dlopen-mini-HOWTO/C++-dlopen-mini-HOWTO.html">dlopen howto</a>
+ </li>
+ </ul>
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Comparison to the Microsoft DLL:</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p> The Microsoft Windows equivalent to the Linux / Unix shared
+object (".so")
+is the ".dll".
+The Microsoft Windows DLL file usually has the extension ".dll", but
+may also use the extension ".ocx". On the old 16 bit windows, the
+dynamically linked libraries were also named with the ".exe" suffix.
+"Executing" the DLL will load it into memory.
+</p>
+ <p>
+The Visual C++ .NET IDE wizard will create a DLL framework through the GUI,
+and generates a ".def" file. This "module definition file" lists the
+functions to be exported. When exporting C++ functions, the C++ mangled
+names are used. Using the Visual C++ compiler to generate a ".map" file
+will allow you to discover the C++ mangled name to use in the ".def" file.
+The "SECTIONS" label in the ".def" file will define the portions which are
+"shared".
+Unfortunately the generation of DLLs are tightly coupled to the Microsoft IDE,
+so much so that I would not recomend trying to create one without it.
+ </p>
+ <p>
+The Microsoft Windows C++ equivalent functions to libdl are the following functions:
+ </p>
+ <ul>
+ <li>::LoadLibrary() - dlopen()
+ </li>
+ <li>::GetProcAddress() - dlsym()
+ </li>
+ <li>::FreeLibrary() - dlclose()
+ </li>
+ </ul>
+ <p>
+ <font color="#ff0000">[Potential Pitfall]</font>: Microsoft Visual C++ .NET compilers do not allow the linking controll that the GNU linker "ld" allows (i.e. --whole-archive, -no-whole-archive).
+All symbols need to be resolved by the VC++ compiler for both the loadable library and the application executable individually and thus it can cause duplication of libraries when the library is loaded.
+This is especially bad when using static variables (i.e. used in singleton patterns) as you will get two memory locations for the static variable, one used by the loadable library and the other used by the program executable.
+This breaks the whole static variable concept and the singleton pattern.
+Thus you can not use a static variable which is referenced by by both the loadable library and the application executable as they will be unique and different.
+To use a unique static variable, you must pass a pointer to that static variable to the other module so that each module (main executable and DLL library) can use the same instatiation.
+On MS/Windows you can use shared memory or a memory mapped file so that the main executable and DLL library can share a pointer to an address they both will use.
+ </p>
+Cross platform (Linux and MS/Windows) C++ code snippet:
+ <p>
+ </p>
+ Include file declaration: (.h or .hpp)
+ <dl><dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>
+class Abc{
+public:
+ static Abc* Instance(); // Function declaration. Could also be used as a public class member function.
+
+private:
+ static Abc *mInstance; // Singleton. Use this declaration in C++ class member variable declaration.
+ ...
+}
+ </pre>
+ </td></tr></tbody></table>
+ </dd></dl>
+ <p>
+ </p>
+ C/C++ Function source: (.cpp)
+ <dl><dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>
+/// Singleton instantiation
+Abc* Abc::mInstance = 0; // Use this declaration for C++ class member variable
+ // (Defined outside of class definition in ".cpp" file)
+
+// Return unique pointer to instance of Abc or create it if it does not exist.
+// (Unique to both exe and dll)
+
+static Abc* Abc::Instance() // Singleton
+{
+#ifdef WIN32
+ // If pointer to instance of Abc exists (true) then return instance pointer else look for
+ // instance pointer in memory mapped pointer. If the instance pointer does not exist in
+ // memory mapped pointer, return a newly created pointer to an instance of Abc.
+
+ return mInstance ?
+ mInstance : (mInstance = (Abc*) MemoryMappedPointers::getPointer("Abc")) ?
+ mInstance : (mInstance = (Abc*) MemoryMappedPointers::createEntry("Abc",(void*)new Abc));
+#else
+ // If pointer to instance of Abc exists (true) then return instance pointer
+ // else return a newly created pointer to an instance of Abc.
+
+ return mInstance ? mInstance : (mInstance = new Abc);
+#endif
+}
+ </pre>
+ </td></tr></tbody></table>
+ </dd></dl>
+Windows linker will pull two instances of object, one in exe and one in loadable module.
+Specify one for both to use by using memory mapped pointer so both exe and loadable library point to same variable or object.
+<br />
+Note that the GNU linker does not have this problem.
+ <p>
+ </p>
+For more on singletons see the YoLinux.com <a href="C++Singleton.html">C++ singleton software design pattern tutorial</a>.
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Cross platform programming of loadable libraries:</big></b></td>
+ </tr>
+ </tbody>
+ </table>
+ <p>
+ </p>
+ <dl>
+ <dd>
+ <table bgcolor="#000000" border="0" cellpadding="4" cellspacing="1" width="100%">
+ <tbody>
+ <tr bgcolor="#c0c0c0">
+ <td>
+ <pre>
+#ifndef USE_PRECOMPILED_HEADERS
+#ifdef WIN32
+#include &lt;direct.h&gt;
+#include &lt;windows.h&gt;
+#else
+#include &lt;sys/types.h&gt;
+#include &lt;dlfcn.h&gt;
+#endif
+#include &lt;iostream&gt;
+#endif
+
+ using namespace std;
+
+#ifdef WIN32
+ HINSTANCE lib_handle;
+#else
+ void *lib_handle;
+#endif
+
+ // Where retType is the pointer to a return type of the function
+ // This return type can be int, float, double, etc or a struct or class.
+
+ typedef retType* func_t;
+
+ // load the library -------------------------------------------------
+#ifdef WIN32
+ string nameOfLibToLoad("C:\opt\lib\libctest.dll");
+ lib_handle = LoadLibrary(TEXT(nameOfLibToLoad.c_str()));
+ if (!lib_handle) {
+ cerr &lt;&lt; "Cannot load library: " &lt;&lt; TEXT(nameOfDllToLoad.c_str()) &lt;&lt; endl;
+ }
+#else
+ string nameOfLibToLoad("/opt/lib/libctest.so");
+ lib_handle = dlopen(nameOfLibToLoad.c_str(), RTLD_LAZY);
+ if (!lib_handle) {
+ cerr &lt;&lt; "Cannot load library: " &lt;&lt; dlerror() &lt;&lt; endl;
+ }
+#endif
+
+...
+...
+...
+
+ // load the symbols -------------------------------------------------
+#ifdef WIN32
+ func_t* fn_handle = (func_t*) GetProcAddress(lib_handle, "superfunctionx");
+ if (!fn_handle) {
+ cerr &lt;&lt; "Cannot load symbol superfunctionx: " &lt;&lt; GetLastError() &lt;&lt; endl;
+ }
+#else
+ // reset errors
+ dlerror();
+
+ // load the symbols (handle to function "superfunctionx")
+ func_t* fn_handle= (func_t*) dlsym(lib_handle, "superfunctionx");
+ const char* dlsym_error = dlerror();
+ if (dlsym_error) {
+ cerr &lt;&lt; "Cannot load symbol superfunctionx: " &lt;&lt; dlsym_error &lt;&lt; endl;
+ }
+#endif
+
+...
+...
+...
+
+ // unload the library -----------------------------------------------
+
+#ifdef WIN32
+ FreeLibrary(lib_handle);
+#else
+ dlclose(lib_handle);
+#endif
+ </pre>
+ </td></tr></tbody></table>
+ </dd></dl>
+
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Tools:</big></b></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>
+ <b>Man pages:</b>
+ </p>
+ <ul>
+
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ar">ar</a> - create, modify, and extract from archives
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ranlib">ranlib</a> - generate index to archive
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=nm">nm</a> - list symbols from object files
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ld">ld</a> - Linker
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ldconfig">ldconfig</a> - configure dynamic linker run-time bindings
+ <br />
+
+ <tt>ldconfig -p</tt> : Print the lists of directories and candidate libraries stored in the current cache.
+ <br />
+i.e. <tt>/sbin/ldconfig -p |grep libGL</tt>
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ldd">ldd</a> - print shared library dependencies
+ </li>
+ <li><a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=gcc">gcc/g++</a> - GNU project C and C++ compiler
+ </li>
+ <li>man page to: <a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ld.so">ld.so</a> - a.out dynamic linker/loader
+ </li>
+ </ul>
+
+
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Notes:</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>
+ </p>
+ <ul>
+
+ <li>Direct loader to preload a specific shared library before all others: <tt>export LD_PRELOAD=/usr/lib/libXXX.so.x; exec <i>program</i></tt>. This is specified in the file <tt>/etc/ld.so.preload</tt> and extended with the environment variable <tt>LD_PRELOAD</tt>.
+ <br />
+Also see:
+
+ <ul>
+
+ <li>man page to: <a href="http://man.yolinux.com/cgi-bin/man2html?cgi_command=ld.so">ld.so</a> - a.out dynamic linker/loader
+ </li>
+ <li><a href="http://www.uberhip.com/people/godber/interception/index.html">LD_PRELOAD and Linux function interception</a>.
+ </li>
+ </ul>
+
+ <p>
+ </p>
+ </li>
+ <li>Running Red Hat 7.1 (glibc 2.2.2) but compiling for Red Hat 6.2 compatibility.
+ <br />
+
+ See <a href="ftp://herbie.ucs.indiana.edu/pub/linux/redhat/redhat/redhat-7.1-en/os/i386/RELEASE-NOTES">RELEASE-NOTES</a>
+ <br />
+
+
+ <pre> export LD_ASSUME_KERNEL=2.2.5<br /> . /usr/i386-glibc21-linux/bin/i386-glibc21-linux-env.sh<br /> </pre>
+
+ <p>
+ </p>
+ </li>
+ <li>Environment variable to highlight warnings, errors, etc: <tt>export CC="colorgcc"</tt>
+ <p>
+ </p>
+ </li>
+ </ul>
+
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>YoLinux Software Development Tutorials:</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>
+ </p>
+ <dl>
+ <dd>
+ <ul>
+
+ <li>Editors:
+
+ <ul>
+
+ <li><a href="LinuxTutorialAdvanced_vi.html"><b>VI</b> / <b>VIM</b> - Advanced editing</a> - tutorial, tips and tricks
+ </li>
+ <li><a href="LinuxTutorialXemacs.html"><b>X-Emacs</b> - Editing C++ code </a> - Use, settings, code beautification
+ </li>
+ </ul>
+
+
+ </li>
+ <li>Source Code Control/Revision:
+
+ <ul>
+
+ <li><a href="LinuxTutorialCVSintro.html"><b>CVS</b> source code control</a> - Track and manage a set of files and their revisions.
+ </li>
+ <li><a href="LinuxTutorialRCSinto.html"><b>RCS</b> source code control</a> - Track and manage individual files and their revisions.
+ </li>
+ <li>IBM/Rational <b>Clearcase</b>:
+
+ <ul>
+
+
+ <li><a href="LinuxClearcaseClient.html">Clearcase Client Installation</a>
+ </li>
+ <li><a href="ClearcaseCommands.html">Clearcase commands</a>
+ </li>
+ </ul>
+
+ </li>
+ </ul>
+
+ </li>
+ <li><a href="LinuxTutorialC++.html">C++ Programming on Linux</a>:
+
+ <ul>
+
+ <li><a href="LinuxTutorialC++STL.html">C++ <b>STL</b> (Standard Template Library) example for Linked Lists</a>
+
+ </li>
+ <li><a href="LinuxTutorialC++StringClass.html">Linux/<b>Gnu C++ string class</b> examples and tutorial</a>
+ </li>
+ <li><a href="LinuxTutorialC++Structures.html">Use of structures in C++</a> - This example shows the use of a constructor with a structure. The stuff they never included in the text books.
+ </li>
+ <li><a href="LinuxTutorialC++CGI.html">Programming web server CGI programs with C++ and the GNU CgiCC library</a>
+ </li>
+ <li><a href="LinuxTutorialC++CodingStyle.html">C++ Coding styles and practices</a>
+ </li>
+ <li><a href="C++MemoryCorruptionAndMemoryLeaks.html">C++ Memory corruption and leaks</a>
+ </li>
+ </ul>
+
+ </li>
+ <li><a href="MicrosoftVisualC++Tips.html">Tips and Best Practices for Microsoft Visual C++ users</a> (So they don't make ugly files and mess up your project.)
+ </li>
+ <li><a href="CORBA.html"><b>CORBA</b>, OmniORB, C++ and remote services (client/server request)</a>
+ </li>
+ <li><a href="ForkExecProcesses.html">Fork, exec and process control</a>
+ </li>
+ <li><b>Threads:</b>
+
+ <ul>
+
+ <li><a href="LinuxTutorialPosixThreads.html">POSIX Threads</a> - make your code run faster and more scalable.
+ </li>
+ <li><a href="GDK_Threads.html">GNOME GDK Threads (g_threads)</a> - Cross platform threads API.
+ </li>
+ </ul>
+
+
+ </li>
+ <li><a href="GTK+ProgrammingTips.html">GNOME <b>GTK+</b> Programming Tips and Tricks</a> - Using the GTK+ cross platform GUI API to build an interactive application.
+ </li>
+ <li><a href="GnomeLibXml2.html">XML and parsing <b>XML</b> with <b>Gnome libXML2</b></a>
+ </li>
+ <li><a href="LinuxTutorialMixingFortranAndC.html">Mixing C and FORTRAN language subroutines</a>
+ </li>
+ <li><a href="LinuxTutorialJava.html"><b>JAVA</b> on Linux</a>
+ </li>
+ <li><a href="LinuxTutorialLDAP-SoftwareDevelopment.html">OpenLDAP C programming SDK Man Pages, RFC's and Links</a>
+ </li>
+ </ul>
+
+ <p>
+ </p>
+ </dd>
+ </dl>
+
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td><b><big>Links:</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>
+ </p>
+ <ul>
+
+ <li><a href="http://www.gnu.org/software/libtool/libtool.html">GNU: Libtool</a> - script for portable shared library creation.
+ </li>
+ <li><a href="http://www.suse.de/%7Ebastian/Export/linking.txt">Suse.de: Discussion of improvement in ld.so for performance improvement.</a>
+ </li>
+ <li><a href="http://www.tldp.org/HOWTO/Program-Library-HOWTO/">LDP Library Howto</a>
+ </li>
+ </ul>
+
+ <p>
+ </p>
+ <hr />
+ <table border="0" cellpadding="2" cellspacing="0" width="100%">
+
+ <tbody>
+ <tr bgcolor="#ffcc33">
+ <td valign="top"><img src="images/book40.gif" alt="Books" /><b><big>Books:</big></b></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p>
+ </p>
+ <dl>
+ <dd>
+ <table cellpadding="5" border="1">
+
+ <tbody>
+ <tr>
+ <td><img src="../BOOKS/0735710430.01.MZZZZZZZ.jpg" alt="Book image" /></td>
+
+ <td valign="top">
+ "Advanced Linux Programming"
+ <br />
+
+ by Mark Mitchell, Jeffrey Oldham, Alex Samuel, Jeffery Oldham
+ <br />
+
+ ISBN # 0735710430, New Riders
+
+ <p>
+ Good book for programmers who already know how to program and just need
+ to know the Linux specifics. Covers a variety of Linux tools, libraries,
+ API's and techniques. If you don't know how to program, start with a
+ book on C.
+ </p>
+ </td>
+
+ <td valign="top">
+ <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http://www.amazon.com/exec/obidos/ASIN/0735710430/&tag=yolinux-20"><img src="images/Amazon-BuyABook88x31.gif" alt="Amazon.com" /></a>
+ <br />
+
+ </td>
+ </tr>
+
+
+ <tr>
+ <td><img src="../BOOKS/0764546570.01.MZZZZZZZ.jpg" alt="Book image" /></td>
+
+ <td valign="top">
+ "Linux Programming Bible"
+ <br />
+
+ by John Goerzen
+ <br />
+
+ ISBN # 0764546570, Hungry Minds, Inc
+
+ <p>
+ This covers the next step after "C" programming 101.
+ </p>
+ </td>
+
+ <td valign="top">
+ <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http://www.amazon.com/exec/obidos/ASIN/0764546570/&tag=yolinux-20"><img src="images/Amazon-BuyABook88x31.gif" alt="Amazon.com" /></a>
+ <br />
+
+ </td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ </dd>
+ </dl>
+
+ <p>
+ </p>
+ </td>
+
+ <td bgcolor="#c0c0c0" valign="top" width="160">
+<!-- AddThis Button BEGIN -->
+<div id="bookmark" align="left">
+&nbsp;&nbsp;&nbsp;
+<a href="http://www.addthis.com/bookmark.php?v=250&pub=yolinux" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/lg-bookmark-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a>
+<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=yolinux">
+</script>
+</div>
+<!-- AddThis Button END -->
+<hr />
+<p>
+</p>
+
+<div align="center">
+<script type="text/javascript"><!--
+ e9 = new Object();
+ e9.size = "160x600";
+ e9.addBlockingCategories="Flashing,Pop-under,Pop-up,Floating,Full-page,Survey";
+ e9.noAd = 1;
+//--></script>
+<script type="text/javascript" src="http://tags.expo9.exponential.com/tags/YoLinuxcom/ROS/tags.js"></script>
+</div>
+
+<p>
+</p>
+<hr />
+<p>
+</p>
+
+<div align="center">
+<!-- Rubicon Project tag -->
+<!-- Site: YoLinux.com Zone: My Site Size: Wide Skyscraper (160x600) -->
+<script language="JavaScript" type="text/javascript">
+var cb = Math.random();
+var d = document;
+d.write('<script language="JavaScript" type="text/javascript"');
+d.write('src="http://optimized-by.rubiconproject.com/a/6142/8070/13650-9.js?cb='+cb+'">');
+d.write('<\/scr'+'ipt>');
+</script>
+<!-- end Rubicon Project tag -->
+</div>
+<p>
+</p>
+<hr />
+<p>
+</p>
+<iframe src="http://rcm.amazon.com/e/cm?t=yolinux-20&o=1&p=14&l=bn1&mode=pc-hardware&browse=172455&fc1=000000&lt1=_blank&lc1=3366FF&bg1=C0C0C0&f=ifr" marginwidth="0" marginheight="0" width="160" height="600" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe>
+
+<p>
+</p>
+<hr />
+<p>
+</p>
+<script src='http://www.enticelabs.com/EL/assets/js/el_dyn.js?c=aa9f7dfd421da13059aafe6994c77783&h=600&w=160&d=https://www.enticelabs.com:443/EL' type='text/javascript'></script>
+<p>
+</p>
+<hr />
+<p>
+</p>
+
+
+ </td>
+
+ </tr>
+ </tbody>
+</table>
+<table width="100%" bgcolor="#646664" cellpadding="4" background="images/footer_pattern.png">
+<tbody>
+<tr>
+<td valign="top">
+<font size="-1" color="#ffcc33">
+<b>
+<a class="footer" href="http://www.yolinux.com">YoLinux.com Home Page</a>
+<br />
+<a class="footer" href="http://yolinux.com/TUTORIALS/">YoLinux Tutorial Index</a> |
+<a class="footer" href="http://yolinux.com/YoLinux-Terms.html">Terms</a>
+<br />
+<a class="footer" href="http://www.yolinux.com/privacy.html">Privacy Policy</a> |
+<a class="footer" href="http://www.yolinux.com/YoLinux-Advertising.html">Advertise with us</a> |
+<a class="footer" href="../YoLinuxEmailForm.html">Feedback Form</a> |
+<br />
+Unauthorized copying or redistribution prohibited.
+</b>
+</font>
+</td>
+<td align="center" valign="bottom">
+<script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script>
+</td>
+<td align="center" valign="bottom">
+<a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count"></a>
+<script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script>
+</td>
+<td align="center" valign="bottom">
+<script src="http://widgets.digg.com/buttons.js" type="text/javascript"></script>
+<a class="DiggThisButton DiggMedium" rev="linux_unix">
+<span style="display:none">
+YoLinux Tutorials. Linux Information Portal includes informative tutorials and links to many Linux sites.
+</span>
+</a>
+</td>
+<td align="center" valign="bottom">
+<p>
+</p>
+<script type="text/javascript">reddit_target='[LINUX]'</script>
+<script type="text/javascript" src="http://reddit.com/static/button/button1.js"></script>
+<br />
+<!-- AddThis Button BEGIN -->
+<a href="http://www.addthis.com/bookmark.php?v=250&pub=yolinux" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/lg-bookmark-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a>
+<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=yolinux">
+</script>
+<!-- AddThis Button END -->
+</td>
+<td valign="top">
+<div align="right">
+<script type="text/javascript"><!--
+google_ad_client = "pub-8567479315106986";
+/* 234x60, created 4/23/10 */
+google_ad_slot = "8214196957";
+google_ad_width = 234;
+google_ad_height = 60;
+//-->
+</script>
+<script type="text/javascript"
+src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+</div>
+</td>
+</tr>
+</tbody>
+</table>
+<p>
+</p>
+
+<small>Copyright &copy; 2005-2008 by <i>Greg Ippolito</i></small>
+<!-- Start Quantcast tag -->
+<script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script>
+<script type="text/javascript">_qacct="p-ebIBcaVUngFBQ";quantserve();</script>
+<noscript>
+<a href="http://www.quantcast.com/p-ebIBcaVUngFBQ" target="_blank"><img src="http://pixel.quantserve.com/pixel/p-ebIBcaVUngFBQ.gif" style="display: none;" border="0" height="1" width="1" alt="Quantcast"/></a>
+</noscript>
+<!-- End Quantcast tag -->
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+var pageTracker = _gat._getTracker("UA-3317450-1");
+pageTracker._initData();
+pageTracker._trackPageview();
+</script>
+
+</body>
+</html>