⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autobook_167.html

📁 Autoconf使用手册
💻 HTML
字号:
<HTML><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><!-- Created on September, 12  2004 by texi2html 1.64 --><!-- Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)            Karl Berry  <karl@freefriends.org>            Olaf Bachmann <obachman@mathematik.uni-kl.de>            and many others.Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>Send bugs and suggestions to <texi2html@mathematik.uni-kl.de> --><HEAD><TITLE>Autoconf, Automake, and Libtool: libltdl Configury</TITLE><META NAME="description" CONTENT="Autoconf, Automake, and Libtool: libltdl Configury"><META NAME="keywords" CONTENT="Autoconf, Automake, and Libtool: libltdl Configury"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META NAME="Generator" CONTENT="texi2html 1.64"><script language="Javascript"><!--    // Check the browser version.    function checkVersion() {      if (navigator.appVersion.charAt(0)>=3) return true;      if (navigator.appVersion.charAt(0)>=4) return true;      else return false;    }      if (checkVersion()) {             homeon = new Image();             homeon.src = "homeon.png";             homeoff = new Image();             homeoff.src = "home.png";             tocon = new Image();             tocon.src = "tocon.png";             tocoff = new Image();             tocoff.src = "toc.png";             indexon = new Image();             indexon.src = "indexon.png";             indexoff = new Image();             indexoff.src = "index.png";             helpon = new Image();             helpon.src = "helpon.png";             helpoff = new Image();             helpoff.src = "help.png";             backon = new Image();             backon.src = "backon.png";             backoff = new Image();             backoff.src = "back.png";             forwardon = new Image();             forwardon.src = "forwardon.png";             forwardoff = new Image();             forwardoff.src = "forward.png";             prevon = new Image();             prevon.src = "prevon.png";             prevoff = new Image();             prevoff.src = "prev.png";             nexton = new Image();             nexton.src = "nexton.png";             nextoff = new Image();             nextoff.src = "next.png";             upon = new Image();             upon.src = "upon.png";             upoff = new Image();             upoff.src = "up.png";         }     function img_act(imgName) {             if (checkVersion()) {             imgOn = eval(imgName + "on.src");             document [imgName].src = imgOn;             }     }     function img_inact(imgName) {             if (checkVersion()) {             imgOff = eval(imgName + "off.src");             document [imgName].src = imgOff;             }     }// --></SCRIPT></HEAD><BODY LANG="EN" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#6688AA" VLINK="#336688" ALINK="#808080"><A NAME="SEC167"></A><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=10><TR VALIGN="TOP"><TD ALIGN="MIDDLE" WIDTH=50 BGCOLOR="#e6e6e6"><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_166.html#SEC166" onMouseover="img_act('prev')" onMouseout="img_inact('prev')"><IMG SRC="prev.png" BORDER="0" ALT="Back: Using libltdl" ALIGN="MIDDLE" NAME="prev"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_168.html#SEC168" onMouseover="img_act('next')" onMouseout="img_inact('next')"><IMG SRC="next.png" BORDER="0" ALT="Forward: libltdl Memory Management" ALIGN="MIDDLE" NAME="next"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_172.html#SEC172" onMouseover="img_act('back')" onMouseout="img_inact('back')"><IMG SRC="back.png" BORDER="0" ALT="FastBack: Portable Library Design" ALIGN="MIDDLE" NAME="back"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_166.html#SEC166" onMouseover="img_act('up')" onMouseout="img_inact('up')"><IMG SRC="up.png" BORDER="0" ALT="Up: Using libltdl" ALIGN="MIDDLE" NAME="up"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_172.html#SEC172" onMouseover="img_act('forward')" onMouseout="img_inact('forward')"><IMG SRC="forward.png" BORDER="0" ALT="FastForward: Portable Library Design" ALIGN="MIDDLE" NAME="forward"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook.html#SEC_Top" onMouseover="img_act('home')" onMouseout="img_inact('home')"><IMG SRC="home.png" BORDER="0" ALT="Top: Autoconf, Automake, and Libtool" ALIGN="MIDDLE" NAME="home"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_toc.html#SEC_Contents" onMouseover="img_act('toc')" onMouseout="img_inact('toc')"><IMG SRC="toc.png" BORDER="0" ALT="Contents: Table of Contents" ALIGN="MIDDLE" NAME="toc"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_285.html#SEC285" onMouseover="img_act('index')" onMouseout="img_inact('index')"><IMG SRC="index.png" BORDER="0" ALT="Index: Index" ALIGN="MIDDLE" NAME="index"></A></TD></TR><TR VALIGN="TOP" ALIGN="LEFT"><TD VALIGN="MIDDLE" ALIGN="LEFT"><A HREF="autobook_abt.html#SEC_About" onMouseover="img_act('help')" onMouseout="img_inact('help')"><IMG SRC="help.png" BORDER="0" ALT="About: About this document" ALIGN="MIDDLE" NAME="help"></A></TD></TR></TABLE></TD><TD ALIGN="LEFT"><H3> 18.2.1 Configury </H3><!--docid::SEC167::--><P>Because libltdl supports so many different platforms<A NAME="DOCF40" HREF="autobook_fot.html#FOOT40">(40)</A> it needs tobe configured for the host platform before it can be used.</P><P><BLOCKQUOTE>The path of least resistance to successfully integrating libltdl intoyour own project, dictates that the project use Libtool for linking itsmodule loader with libltdl.  This is certainly the method I use andrecommend, and is the method discussed in this chapter.   However, Ihave seen projects which did not use Libtool (specifically becauseLibtool's poor C++ support made it difficult to adopt), but which wantedthe advantages of libltdl.  It is possible to use libltdl entirelywithout Libtool, provided you take care to use the configuration macrosdescribed here, and use the results of those running these macros todetermine how to link your application with libltdl.</BLOCKQUOTE><P>The easiest way to add libltdl support to your own projects is with thefollowing simple steps:</P><P><OL><LI>You must add the libltdl sources to your project distribution.If you are not already using Libtool in some capacity for your project,you should add <SAMP>`AC_PROG_LIBTOOL'</SAMP><A NAME="DOCF41" HREF="autobook_fot.html#FOOT41">(41)</A>  to your <TT>`configure.in'</TT>.  Thatdone, move to the top level directory of the project, and execute:<P><TABLE width=100%><tr><td>&nbsp;</td><td class=example bgcolor=#6688aa><br><pre>$ libtoolize --ltdl$ ls -Faclocal.m4    configure.in    libltdl/$ ls libltdl/COPYING.LIB   README         aclocal.m4    configure.in   stamp-h.inMakefile.am   acconfig.h     config.h.in   ltdl.c  Makefile.in   acinclude.m4   configure     ltdl.h </pre></td></tr></table></P><P><LI>libltdl has its own configuration to run in addition to theconfiguration for your project, so you must be careful to call thesubdirectory configuration from your top level <TT>`configure.in'</TT>:<P><TABLE width=100%><tr><td>&nbsp;</td><td class=example bgcolor=#6688aa><br><pre>AC_CONFIG_SUBDIRS(libltdl)</pre></td></tr></table></P><P>And you must ensure that Automake knows that it must descend into thelibltdl source directory at make time, by adding the name of thatsubdirectory to the <SAMP>`SUBDIRS'</SAMP> macro in your top level<TT>`Makefile.am'</TT>:</P><P><TABLE width=100%><tr><td>&nbsp;</td><td class=example bgcolor=#6688aa><br><pre>SUBDIRS = libltdl src</pre></td></tr></table></P><P><LI>You must also arrange for the code of libltdl to be linked intoyour application.  There are two ways to do this: as a regular Libtoollibrary; or as a convenience library (see section <A HREF="autobook_74.html#SEC74">Creating Convenience Libraries</A>).  Either waythere are catches to be aware of, which will be addressed in a futurerelease.  Until libltdl is present on the average user's machine, Irecommend  building a convenience library.  You can do that in<TT>`configure.in'</TT>: <P><TABLE width=100%><tr><td>&nbsp;</td><td class=example bgcolor=#6688aa><br><pre>AC_LIBLTDL_CONVENIENCEAC_PROG_LIBTOOL</pre></td></tr></table></P><P>The main thing to be aware of when you follow these steps, is that youcan only have one copy of the code from libltdl in anyapplication. Once you link the objects into a library, that library willnot work with any other library which has also linked withlibltdl, or any application which has its own copy of theobjects.  If you were to try, the libltdl symbol names wouldclash.</P><P>The alternative is to substitute <SAMP>`AC_LIBLTDL_CONVENIENCE'</SAMP> with<BR><SAMP>`AC_LIBLTDL_INSTALLABLE'</SAMP>.  Unfortunately there are currently manypotential problems with this approach.  This macro will try to find analready installed libltdl and use that, or else the embeddedlibltdl will be built as a standard shared library, which must beinstalled along with any libraries or applications that use it.  Thereis no testing for version compatibility, so it is possible that two ormore applications that use this method will overwrite one anotherscopies of the installed libraries and headers.  Also, the code whichsearches for the already installed version of libltdl tends notto find the library on many hosts, due to the native libraries itdepends on being difficult to predict.</P><P>Both of the <SAMP>`AC_LIBLTDL_...'</SAMP> macros set the values of<SAMP>`INCLTDL'</SAMP> and <SAMP>`LIBLTDL'</SAMP> so that they can be used to add thecorrect include and library flags to the compiler in your Makefiles.They are not substituted by default.  If you need to use them you mustalso add the following macros to your <TT>`configure.in'</TT>:</P><P><TABLE width=100%><tr><td>&nbsp;</td><td class=example bgcolor=#6688aa><br><pre>AC_SUBST(INCLTDL)AC_SUBST(LIBLTDL)</pre></td></tr></table></P><P><LI>Many of the libltdl supported hosts require that a separateshared library be linked into any application that uses dynamic runtimeloading.  libltdl is wrapped around this native implementation onthese hosts, so it is important to link that library too.  Addingsupport for module loading through the wrapped native implementation isindependent of Libtool's determination of how shared objects arecompiled.  On GNU/Linux, you would need to link your program withlibltdl and <TT>`libdl'</TT>, for example.<P>Libtool installs a macro, <SAMP>`AC_LIBTOOL_DLOPEN'</SAMP>, which adds tests toyour <TT>`configure'</TT> that will search for this native library.Whenever you use libltdl you should add this macro to your<TT>`configure.in'</TT> before <SAMP>`AC_PROG_LIBTOOL'</SAMP>: </P><P><TABLE width=100%><tr><td>&nbsp;</td><td class=example bgcolor=#6688aa><br><pre>AC_LIBTOOL_DLOPENAC_LIBLTDL_CONVENIENCEAC_PROG_LIBTOOL...AC_SUBST(INCLTDL)AC_SUBST(LIBLTDL)</pre></td></tr></table></P><P><SAMP>`AC_LIBTOOL_DLOPEN'</SAMP> takes care to substitute a suitable value of<SAMP>`LIBADD_DL'</SAMP> into your <TT>`Makefile.am'</TT>, so that your code willcompile correctly wherever the implementation library is discovered:</P><P><TABLE width=100%><tr><td>&nbsp;</td><td class=example bgcolor=#6688aa><br><pre>INCLUDES        += @INCLTDL@bin_PROGRAMS     = your_appyour_app_SOURCES = main.c support.cyour_app_LDADD   = @LIBLTDL@ @LIBADD_DL@</pre></td></tr></table></OL><P>Libtool 1.4 has much improved inter-library dependency tracking codewhich no longer requires <SAMP>`@LIBADD_DL@'</SAMP> be explicitly referencedin your <TT>`Makefile.am'</TT>.    When you install libltdl, Libtool 1.4 (orbetter) will make a note of any native library that libltdl depends on --linking it automatically, provided that you link <TT>`libltdl.la'</TT> with<CODE>libtool</CODE>.  You might want to omit the <SAMP>`@LIBADD_DL@'</SAMP> fromyour <TT>`Makefile.am'</TT> in this case, if seeing the native library twice(once as a dependee of libltdl, and again as an expansion of<SAMP>`@LIBADD_DL@'</SAMP>) on the link line bothers you.</P><P>Beyond this basic configury setup, you will also want to write some codeto form a module loading subsystem for your project, and of course somemodules!  That process is described in <A HREF="autobook_169.html#SEC169">Module Loader</A> and <A HREF="autobook_171.html#SEC171">Dynamic Module</A>respectively.</P><P><A NAME="libltdl Memory Management"></A></TR></TABLE><BR>  <FONT SIZE="-1">This document was generatedby <I>Gary V. Vaughan</I> on <I>September, 12  2004</I>using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html"><I>texi2html</I></A></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -