Index: libtool.texi =================================================================== RCS file: /cvsroot/libtool/libtool/doc/libtool.texi,v retrieving revision 1.192 diff -u -p -u -r1.192 libtool.texi --- libtool.texi 30 Apr 2005 09:30:14 -0000 1.192 +++ libtool.texi 11 Aug 2005 11:38:49 -0000 @@ -609,22 +612,30 @@ shared libraries, libtool simply acts as @cindex libtool libraries @cindex @samp{.la} files -Again, the libtool library name differs from the standard name (it has a address@hidden suffix instead of a @samp{.a} suffix). The arguments to +Again, the libtool control file name (@samp{.la} suffix) differs from +the standard library name (@samp{.a} suffix). The arguments to libtool are the same ones you would use to produce an executable named @file{libhello.la} with your compiler (@pxref{Link mode}): @example -a23$ @kbd{libtool link gcc -g -O -o libhello.la foo.o hello.o} -libtool: cannot build libtool library `libhello.la' from non-libtool \ - objects +a23$ @kbd{libtool --mode=link gcc -g -O -o libhello.la foo.o hello.o} +*** Warning: Linking the shared library libhello.la against the non-libtool +*** objects foo.o hello.o is not portable! +ar cru .libs/libhello.a +ranlib .libs/libhello.a +creating libhello.la +(cd .libs && rm -f libhello.la && ln -s ../libhello.la libhello.la) a23$ @end example Aha! Libtool caught a common address@hidden trying to build a library -from standard objects instead of library objects. This doesn't matter -so much for static libraries, but on shared library systems, it is of -great importance. +from standard objects instead of special @samp{.lo} object files. This +doesn't matter so much for static libraries, but on shared library +systems, it is of great importance. (Note that you may replace address@hidden with @samp{libhello.a} in which case : Libtool won't +issue the warning any more. But although this method works, this is +not intended to be used be cause it makes you lose the benefits of +using Libtool.) So, let's try again, this time with the library object files. Remember also that we need to add @option{-lm} to the link command line because @@ -638,7 +649,7 @@ specify an @code{rpath}, then libtool bu archive, not a shared library (@pxref{Static libraries}).}: @example -a23$ @kbd{libtool link gcc -g -O -o libhello.la foo.lo hello.lo \ +a23$ @kbd{libtool --mode=link gcc -g -O -o libhello.la foo.lo hello.lo \ -rpath /usr/local/lib -lm} ar cru @value{objdir}/libhello.a foo.o hello.o ranlib @value{objdir}/libhello.a @@ -650,7 +661,7 @@ a23$ Now, let's try the same trick on the shared library platform: @example -burger$ @kbd{libtool link gcc -g -O -o libhello.la foo.lo hello.lo \ +burger$ @kbd{libtool --mode=link gcc -g -O -o libhello.la foo.lo hello.lo \ -rpath /usr/local/lib -lm} rm -fr @value{objdir}/libhello.a @value{objdir}/libhello.la ld -Bshareable -o @value{objdir}/libhello.so.0.0 foo.lo hello.lo -lm @@ -671,6 +682,11 @@ subdirectory, rather than the current di make it easier to clean up the build directory, and to help ensure that other programs fail horribly if you accidentally forget to use libtool when you should. + +Again, you may want to have a look at the @samp{.la} file in order +to see what Libtool stores in it. In particular, you will see that +Libtool uses this file to remember @samp{-rpath} argument as well as +the dependancy on the math library (@samp{-lm}). @node Linking executables @section Linking executables