This commit is contained in:
gferg 2000-09-09 21:13:50 +00:00
parent 97feca872e
commit 9baedf1de8
3 changed files with 81 additions and 14 deletions

View File

@ -1529,7 +1529,7 @@ automatically if they die (without any manual intervention). </Para>
Program-Library-HOWTO</ULink>,
<CiteTitle>Program Library HOWTO</CiteTitle>
</Para><Para>
<CiteTitle>Updated: July 2000</CiteTitle>.
<CiteTitle>Updated: September 2000</CiteTitle>.
This HOWTO for programmers discusses how to create and use program
libraries on Linux. This includes static libraries, shared libraries,
and dynamically loaded libraries. </Para>

View File

@ -201,7 +201,7 @@ Describes the Linux approach to Tcl, a scripting language. </Para>
Program-Library-HOWTO</ULink>,
<CiteTitle>Program Library HOWTO</CiteTitle>
</Para><Para>
<CiteTitle>Updated: July 2000</CiteTitle>.
<CiteTitle>Updated: September 2000</CiteTitle>.
This HOWTO for programmers discusses how to create and use program
libraries on Linux. This includes static libraries, shared libraries,
and dynamically loaded libraries. </Para>

View File

@ -7,7 +7,7 @@
<author><firstname>David A.</firstname> <surname>Wheeler</surname>
</author>
<address><email>dwheeler@dwheeler.com</email></address>
<pubdate>version 0.65, 25 July 2000</pubdate>
<pubdate>version 0.71, 6 September 2000</pubdate>
<abstract>
<para>
This HOWTO for programmers
@ -18,7 +18,7 @@ dynamically loaded libraries.
</abstract>
</artheader>
<sect1>
<sect1 id="introduction">
<title>Introduction</title>
<para>
This HOWTO for programmers
@ -100,7 +100,7 @@ General Public License (GPL); see the last section for more information.
</para>
</sect1>
<sect1>
<sect1 id="static-libraries">
<title>Static Libraries</title>
<para>
Static libraries are simply a collection of ordinary object files;
@ -152,7 +152,7 @@ ld(1) is more likely to change.
</para>
</sect1>
<sect1>
<sect1 id="shared-libraries">
<title>Shared Libraries</title>
<para>
@ -383,6 +383,11 @@ SHLIB_PATH, and on AIX this functionality is through LIBPATH.
<!-- Source for the systems that don't use LD_LIBRARY_PATH:
Drazen Kacar dave@srce.hr, 20 Jul 2000 13:27:53 +0200,
Mailing list gnome-devel-list@gnome.org -->
Also, LD_LIBRARY_PATH is handy for development and testing, but shouldn't
be modified by an installation process for normal use; see
``Why LD_LIBRARY_PATH is Bad'' at
<ulink url="http://www.visi.com/~barr/ldpath.html">http://www.visi.com/~barr/ldpath.html</ulink>
for an explanation of why.
</para>
<para>
@ -558,7 +563,7 @@ program directly; an untrusted program could execute unexpected code.
<para>
When a new version of a library is binary-incompatible with the old one
the soname needs to change.
There are four basic reasons that a library would cease to
In C, there are four basic reasons that a library would cease to
be binary compatible:
<orderedlist>
<listitem><para>The behavior of a function changes so that it no longer
@ -587,10 +592,72 @@ application) to allocate the structure, making the extra items optional
Watch out - you probably
can't expand structures if users are using them in arrays.
</para>
<para>
For C++ (and other languages supporting compiled-in templates and/or
compiled dispatched methods), the situation is trickier.
All of the above issues apply, plus many more issues.
The reason is that some information is implemented ``under the covers''
in the compiled code, resulting in dependencies that may not be obvious
if you don't know how C++ is typically implemented.
Strictly speaking, they aren't ``new'' issues, it's just that compiled C++
code invokes them in ways that may be surprising to you.
The following is a (probably incomplete) list of things that you cannot
do in C++ and retain binary compatibility, as reported by
<ulink url="http://www.trolltech.com/developer/faq/tech.html#bincomp">
Troll Tech's Technical FAQ</ulink>:
<orderedlist>
<listitem><para>
add reimplementations of virtual functions
(unless it it safe for older binaries to call the original implementation),
because the compiler evaluates SuperClass::virtualFunction() calls
at compile-time (not link-time).
</para></listitem>
<listitem><para>
add or remove virtual member functions, because
this would change the size and layout of the vtbl of every subclass.
</para></listitem>
<listitem><para>
change the type of any data members or move any data members
that can be accessed via inline member functions.
</para></listitem>
<listitem><para>
change the class hierarchy, except to add new leaves.
</para></listitem>
<listitem><para>
add or remove private data members, because
this would change the size and layout of every subclass.
</para></listitem>
<listitem><para>
remove public or protected member functions unless they are inline.
</para></listitem>
<listitem><para>
make a public or protected member function inline.
</para></listitem>
<listitem><para>
change what an inline function does, unless the old version continues working.
</para></listitem>
<listitem><para>
change the access rights
(i.e. public, protected or private) of a member function in a
portable program, because
some compilers mangle the access rights into the function name.
</para></listitem>
</orderedlist>
</para>
<para>
Given this lengthy list, developers of C++ libraries in particular must
plan for more than occasional updates that break binary compatibility.
Fortunately, on Unix-like systems (including Linux) you can have
multiple versions of a library loaded at the same time, so while there
is some disk space loss, users can still run ``old'' programs needing
old libraries.
</para>
</sect2>
</sect1>
<sect1>
<sect1 id="dl-libraries">
<title>Dynamically Loaded (DL) Libraries</title>
<para>
Dynamically loaded (DL) libraries are libraries that are loaded
@ -826,7 +893,7 @@ the ``-rdynamic'' flag doesn't always work for gcc on non-Linux systems.
</sect1>
<sect1>
<sect1 id="miscellaneous">
<title>Miscellaneous</title>
<sect2>
@ -924,7 +991,7 @@ For more information, see its documentation at
</sect2>
</sect1>
<sect1>
<sect1 id="more-examples">
<title>More Examples</title>
<para>
The following are more examples of all three approaches
@ -1183,7 +1250,7 @@ LD_LIBRARY_PATH="." ./demo_dynamic
<!-- END OF demo.sgml -->
</sect1>
<sect1>
<sect1 id="info-sources">
<title>Other Information Sources</title>
<para>
Particularly useful sources of information about libraries
@ -1208,8 +1275,8 @@ See
<ulink url="ftp://tsx-11.mit.edu/pub/linux/packages/GCC/ELF.doc.tar.gz">ftp://tsx-11.mit.edu/pub/linux/packages/GCC/ELF.doc.tar.gz</ulink>
If you get the file from MIT, note that the format is unusual;
after gunzipping and untarring, you'll get an ``hps'' file; just
strip off the top and bottom lines and you'll get a printable
Postscript file.
strip off the top and bottom lines, rename it to a ``ps'' file,
and you'll get a printable Postscript file with the usual filename.
</para></listitem>
<listitem><para>
``ELF: From the Programmer's Perspective'' by
@ -1221,7 +1288,7 @@ available at
</para>
</sect1>
<sect1>
<sect1 id="copyright">
<title>Copyright and License</title>
<para>
This document is Copyright (C) 2000 David A. Wheeler.