libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the wrong library


From: Benjamin Reed
Subject: Re: Getting the wrong library
Date: Sun, 01 Jun 2003 13:13:27 -0400
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.3; StumbleUpon.com) Gecko/20030529

Peter O'Gorman wrote:

The problem being the /opt/local/lib/libfreetype.dylib... it should have linked against /usr/X11R6/lib/libfreetype.dylib, but because there is no .la in /usr/X11R6/lib and there was a .la in /opt/local/lib, it found the wrong one.

After looking into this a bit, it seems that the search *should* happen,
as that's how dependent libraries get added to the linker command-line.
  However, the current behavior is causing the library paths to
effectively not necessarily be searched in the order they should be.

To expand on this, what's happening is if you have a search path of:

   /usr/X11R6/lib /usr/local/lib /usr/lib

If there is a libfoo.so in /usr/X11R6/lib and libfoo.la in
/usr/local/lib, it will pick the libfoo.la instead of the one from
/usr/X11R6/lib, which ends up pointing to the wrong library.

Attached is a patch to fix this.  This works on darwin and should work
on anything else as I'm using $shrext as part of the extension search.



Index: ChangeLog
===================================================================
RCS file: /cvsroot/libtool/libtool/ChangeLog,v
retrieving revision 1.1229
diff -u -r1.1229 ChangeLog
--- ChangeLog   30 May 2003 15:25:10 -0000      1.1229
+++ ChangeLog   1 Jun 2003 17:05:36 -0000
@@ -1,3 +1,8 @@
+2003-06-01 Benjamin Reed  <address@hidden>
+
+       * ltmain.in: search libraries in the order of preference, rather
+       than picking .la's even if they're in a less preferred directory.
+
 2003-05-30  Gary V. Vaughan  <address@hidden>
 
        * libltdl/ltdl.c (argz_insert): Corrected an off by one error when
Index: ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/ltmain.in,v
retrieving revision 1.335
diff -u -r1.335 ltmain.in
--- ltmain.in   9 Apr 2003 17:54:06 -0000       1.335
+++ ltmain.in   1 Jun 2003 16:45:14 -0000
@@ -1813,12 +1813,18 @@
          fi
          name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
          for searchdir in $newlib_search_path $lib_search_path 
$sys_lib_search_path $shlib_search_path; do
-           # Search the libtool library
-           lib="$searchdir/lib${name}.la"
-           if test -f "$lib"; then
-             found=yes
-             break
-           fi
+           for search_ext in la $shrext so a; do
+             # Search the libtool library
+             lib="$searchdir/lib${name}.${search_ext}"
+             if test -f "$lib"; then
+               if test "$search_ext" = "la"; then
+                 found=yes
+               else
+                 found=no
+               fi
+               break 2
+             fi
+           done
          done
          if test "$found" != yes; then
            # deplib doesn't seem to be a libtool library

Attachment: pgp0FaekzE7iv.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]