mirror of https://github.com/tLDP/LDP
updated
This commit is contained in:
parent
0bb3a0d82b
commit
3b510706fb
|
@ -2084,7 +2084,7 @@ automatically if they die (without any manual intervention). </Para>
|
|||
Program-Library-HOWTO</ULink>,
|
||||
<CiteTitle>Program Library HOWTO</CiteTitle>
|
||||
</Para><Para>
|
||||
<CiteTitle>Updated: September 2001</CiteTitle>.
|
||||
<CiteTitle>Updated: March 2002</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>
|
||||
|
|
|
@ -226,7 +226,7 @@ Describes the Linux approach to Tcl, a scripting language. </Para>
|
|||
Program-Library-HOWTO</ULink>,
|
||||
<CiteTitle>Program Library HOWTO</CiteTitle>
|
||||
</Para><Para>
|
||||
<CiteTitle>Updated: September 2001</CiteTitle>.
|
||||
<CiteTitle>Updated: March 2002</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>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<author><firstname>David A.</firstname> <surname>Wheeler</surname>
|
||||
</author>
|
||||
<address><email>dwheeler@dwheeler.com</email></address>
|
||||
<pubdate>version 0.91, 14 September 2001</pubdate>
|
||||
<pubdate>version 1.00, 22 March 2002</pubdate>
|
||||
<abstract>
|
||||
<para>
|
||||
This HOWTO for programmers
|
||||
|
@ -510,8 +510,9 @@ should not be unduly affected by the environment variables set.
|
|||
<para>
|
||||
Creating a shared library is easy.
|
||||
First, create the object files that will go into the shared
|
||||
library using the gcc -fPIC flag (this enables the ``position independent
|
||||
code'' generation, a requirement for shared libraries).
|
||||
library using the gcc -fPIC or -fpic flag.
|
||||
The -fPIC and -fpic options enable ``position independent code'' generation,
|
||||
a requirement for shared libraries; see below for the differences.
|
||||
Then create the shared library using this format:
|
||||
</para>
|
||||
|
||||
|
@ -526,7 +527,7 @@ creates a shared library that contains both of them.
|
|||
Note that this compilation includes debugging information (-g) and
|
||||
will generate warnings (-Wall), which aren't required for shared libraries
|
||||
but are recommended.
|
||||
The compilation generates object files (using -c), and obviously includes
|
||||
The compilation generates object files (using -c), and includes
|
||||
the required -fPIC option:
|
||||
</para>
|
||||
|
||||
|
@ -545,9 +546,18 @@ compiler option -fomit-frame-pointer unless you really have to.
|
|||
The resulting library will work, but these actions make debuggers
|
||||
mostly useless.</para>
|
||||
</listitem>
|
||||
<listitem><para>Use -fPIC to generate code,
|
||||
not -fpic (the latter may not work, because if branches need large
|
||||
displacements -fpic may not generate fully position-independent code).</para>
|
||||
<listitem><para>Use -fPIC or -fpic to generate code.
|
||||
Whether to use -fPIC or -fpic to generate code is target-dependent.
|
||||
The -fPIC choice always works, but may produce larger code than -fpic
|
||||
(mnenomic to remember this is that PIC is in a larger case,
|
||||
so it may produce larger amounts of code).
|
||||
Using -fpic option usually generates
|
||||
smaller and faster code, but will have platform-dependent
|
||||
limitations, such as the number of globally visible symbols or
|
||||
the size of the code. The linker will tell you whether it fits
|
||||
when you create the shared library.
|
||||
When in doubt, I choose -fPIC, because it always works.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem><para>
|
||||
In some cases, the call to gcc to create the object file
|
||||
|
@ -556,7 +566,7 @@ Normally, the dynamic symbol
|
|||
table contains only symbols which are used by a dynamic object.
|
||||
This option (when creating an ELF file) adds all symbols to the
|
||||
dynamic symbol table (see ld(1) for more information).
|
||||
You use this option when there are 'reverse dependencies', i.e.,
|
||||
You need to use this option when there are 'reverse dependencies', i.e.,
|
||||
a DL library has unresolved symbols that by convention must be defined
|
||||
in the programs that intend to load these libraries.
|
||||
For ``reverse dependencies'' to work, the master program must make its
|
||||
|
@ -576,7 +586,7 @@ that's also used by many other programs -- and you don't want the
|
|||
other programs to use the ``developmental''library, only a particular
|
||||
application that you're testing against it.
|
||||
One link option you might use is ld's ``rpath'' option, which specifies
|
||||
where the runtime library search path of that particular program
|
||||
the runtime library search path of that particular program
|
||||
being compiled.
|
||||
From gcc, you can invoke the rpath option by specifying it this way:
|
||||
<programlisting>
|
||||
|
@ -609,11 +619,20 @@ a version at all). The simplest approach is to run:
|
|||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Finally, when you compile your programs, you'll need to tell the
|
||||
linker about any static and shared libraries that you're using.
|
||||
Use the -l and -L options for this.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If you can't or don't want to install a library in a standard place
|
||||
(e.g., you don't have the right to modify
|
||||
/usr/lib),
|
||||
(e.g., you don't have the right to modify /usr/lib),
|
||||
then you'll need to change your approach.
|
||||
In that case, you'll need to install it somewhere, and then
|
||||
give your program enough information so the program can find the library...
|
||||
and there are several ways to do that.
|
||||
You can use gcc's -L flag in simple cases.
|
||||
You can use the ``rpath'' approach (described above), particularly if
|
||||
you only have a specific program to use the library being placed in
|
||||
a ``non-standard'' place.
|
||||
|
@ -638,6 +657,8 @@ those functions (leaving others as they were).
|
|||
<para>
|
||||
Usually you can update libraries without concern; if there was an API
|
||||
change, the library creator is supposed to change the soname.
|
||||
That way, multiple libraries can be on a single system, and the right
|
||||
one is selected for each program.
|
||||
However, if a program breaks on an update to a library that kept the
|
||||
same soname, you can force it to use the older library version by
|
||||
copying the old library back somewhere,
|
||||
|
@ -656,7 +677,9 @@ The wrapper script could look something like this:
|
|||
</programlisting>
|
||||
Please don't depend on this when you write your own programs; try to
|
||||
make sure that your libraries are either backwards-compatible or that
|
||||
you've incremented the version number in the soname.
|
||||
you've incremented the version number in the soname every time
|
||||
you make an incompatible change.
|
||||
This is just an ``emergency'' approach to deal with worst-case problems.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
|
|
@ -51,6 +51,14 @@ services for the Apache webserver, and I mention some of them here, as
|
|||
I do for our competitors and similar open source projects.
|
||||
<p>If you find typos, errors, or if you have suggestions for improvement
|
||||
or comments, please let me know so I can correct the document.
|
||||
|
||||
<p>Copyright 2002 Daniel Lopez Ridruejo
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the Open Content Open Publication License, Version
|
||||
1.1. A copy of the license is included in the appendix entitled "Open
|
||||
Content Open Publication License", or at www.opencontent.org/openpub/.
|
||||
|
||||
<sect>Apache
|
||||
<p>Apache is the leading internet web server, with over 60% market share, according
|
||||
to the <url name="Netcraft survey" url="http://www.netcraft.com/survey">.
|
||||
|
@ -997,6 +1005,148 @@ plans that include Apache too.
|
|||
the SGML source. Check <htmlurl url="http://www.linuxdoc.org"> for info.
|
||||
Please drop me a note so I can make sure you get the most recent version.
|
||||
|
||||
<sect>Open Content Open Publication License
|
||||
|
||||
<p>Open Publication License
|
||||
Draft v1.0, 8 June 1999 (text version)
|
||||
|
||||
|
||||
<sect1>REQUIREMENTS ON BOTH UNMODIFIED AND MODIFIED VERSIONS
|
||||
|
||||
<p>The Open Publication works may be reproduced and distributed in
|
||||
whole or in part, in any medium physical or electronic, provided that
|
||||
the terms of this license are adhered to, and that this license or an
|
||||
incorporation of it by reference (with any options elected by the
|
||||
author(s) and/or publisher) is displayed in the reproduction.
|
||||
|
||||
<p>Proper form for an incorporation by reference is as follows:
|
||||
|
||||
<p>Copyright (c) <year> by <author's name or
|
||||
designee>. This material may be distributed only subject to the
|
||||
terms and conditions set forth in the Open Publication License, vX.Y
|
||||
or later (the latest version is presently available at
|
||||
http://www.opencontent.org/openpub/). The reference must be
|
||||
immediately followed with any options elected by the author(s) and/or
|
||||
publisher of the document (see section VI).
|
||||
|
||||
<p>Commercial redistribution of Open Publication-licensed material is
|
||||
permitted.
|
||||
|
||||
<p>Any publication in standard (paper) book form shall require the
|
||||
citation of the original publisher and author. The publisher and
|
||||
author's names shall appear on all outer surfaces of the book. On all
|
||||
outer surfaces of the book the original publisher's name shall be as
|
||||
large as the title of the work and cited as possessive with respect to
|
||||
the title.
|
||||
|
||||
|
||||
<sect1>COPYRIGHT
|
||||
|
||||
<p>The copyright to each Open Publication is owned by its author(s) or designee.
|
||||
|
||||
|
||||
<sect1>SCOPE OF LICENSE
|
||||
|
||||
<p>The following license terms apply to all Open Publication works,
|
||||
unless otherwise explicitly stated in the document.
|
||||
|
||||
<p>Mere aggregation of Open Publication works or a portion of an Open
|
||||
Publication work with other works or programs on the same media shall
|
||||
not cause this license to apply to those other works. The aggregate
|
||||
work shall contain a notice specifying the inclusion of the Open
|
||||
Publication material and appropriate copyright notice.
|
||||
|
||||
<p>SEVERABILITY. If any part of this license is found to be
|
||||
unenforceable in any jurisdiction, the remaining portions of the
|
||||
license remain in force.
|
||||
|
||||
<p>NO WARRANTY. Open Publication works are licensed and provided "as
|
||||
is" without warranty of any kind, express or implied, including, but
|
||||
not limited to, the implied warranties of merchantability and fitness
|
||||
for a particular purpose or a warranty of non-infringement.
|
||||
|
||||
|
||||
<sect1>REQUIREMENTS ON MODIFIED WORKS
|
||||
|
||||
<p>All modified versions of documents covered by this license,
|
||||
including translations, anthologies, compilations and partial
|
||||
documents, must meet the following requirements:
|
||||
|
||||
<itemize>
|
||||
|
||||
<item> 1. The modified version must be labeled as such.
|
||||
|
||||
<item> 2. The person making the modifications must be identified and
|
||||
the modifications dated.
|
||||
|
||||
<item> 3. Acknowledgement of the original author and publisher if
|
||||
applicable must be retained according to normal academic citation
|
||||
practices.
|
||||
|
||||
<item> 4. The location of the original unmodified document must be
|
||||
identified.
|
||||
|
||||
<item> 5. The original author's (or authors') name(s) may not be used
|
||||
to assert or imply endorsement of the resulting document without the
|
||||
original author's (or authors') permission.
|
||||
|
||||
</itemize>
|
||||
|
||||
|
||||
<sect1>GOOD-PRACTICE RECOMMENDATIONS
|
||||
|
||||
<p>In addition to the requirements of this license, it is requested
|
||||
from and strongly recommended of redistributors that:
|
||||
|
||||
<itemize>
|
||||
|
||||
<item> 1. If you are distributing Open Publication works on hardcopy
|
||||
or CD-ROM, you provide email notification to the authors of your
|
||||
intent to redistribute at least thirty days before your manuscript or
|
||||
media freeze, to give the authors time to provide updated
|
||||
documents. This notification should describe modifications, if any,
|
||||
made to the document.
|
||||
|
||||
<item> 2. All substantive modifications (including deletions) be
|
||||
either clearly marked up in the document or else described in an
|
||||
attachment to the document.
|
||||
|
||||
<item> 3. Finally, while it is not mandatory under this license, it is
|
||||
considered good form to offer a free copy of any hardcopy and CD-ROM
|
||||
expression of an Open Publication-licensed work to its author(s).
|
||||
|
||||
</itemize>
|
||||
|
||||
<sect1>LICENSE OPTIONS
|
||||
|
||||
<p>The author(s) and/or publisher of an Open Publication-licensed
|
||||
document may elect certain options by appending language to the
|
||||
reference to or copy of the license. These options are considered part
|
||||
of the license instance and must be included with the license (or its
|
||||
incorporation by reference) in derived works.
|
||||
|
||||
<p>A. To prohibit distribution of substantively modified versions
|
||||
without the explicit permission of the author(s). "Substantive
|
||||
modification" is defined as a change to the semantic content of the
|
||||
document, and excludes mere changes in format or typographical
|
||||
corrections.
|
||||
|
||||
<p>To accomplish this, add the phrase `Distribution of substantively
|
||||
modified versions of this document is prohibited without the explicit
|
||||
permission of the copyright holder.' to the license reference or copy.
|
||||
|
||||
<p>B. To prohibit any publication of this work or derivative works in
|
||||
whole or in part in standard (paper) book form for commercial purposes
|
||||
is prohibited unless prior permission is obtained from the copyright
|
||||
holder.
|
||||
|
||||
<p>To accomplish this, add the phrase 'Distribution of the work or
|
||||
derivative of the work in any standard (paper) book form is prohibited
|
||||
unless prior permission is obtained from the copyright holder.' to the
|
||||
license reference or copy.
|
||||
|
||||
|
||||
|
||||
<!--<sect>Other web servers-->
|
||||
</article>
|
||||
|
||||
|
|
Loading…
Reference in New Issue