bug-libtool
[Top][All Lists]
Advanced

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

Follow up.


From: Carlo Wood
Subject: Follow up.
Date: Wed, 20 Nov 2002 00:57:52 +0100
User-agent: Mutt/1.2.5i

I am not using the following work around:

PREFIX=`$CXX -v 2>&1 | grep 'Reading specs from' | sed -e 's%Reading specs from 
\(.*\)/lib/.*%\1%'`
AC_CHECK_LIB(gmpxx, __gmpz_set, [LIBS="-L$PREFIX/lib -lgmpxx $LIBS"])

Probably the problem is that developers (like me) who use
frequently different compiler versions use scripts
(aka 'g++-3.2') that add this -L prefix themself, and as
such the -L is not part of the commandline that libtool
sees.

The script that I use looks like this:


COMPILER_VERSION=`echo $0 | sed -e 's%^[^-]*-\(.*\)%\1%'`
COMPILER=`echo $0 | sed -e 's%^.*/\(...\)[^/]*%\1%'`
if [ $# = 1 -a $1 = '-v' ]; then
  /usr/local/gcc-$COMPILER_VERSION/bin/$COMPILER -v
  exit 0
fi
(
  (
    if /usr/local/gcc-$COMPILER_VERSION/bin/$COMPILER 
"-Wl,-rpath,/usr/local/gcc-$COMPILER_VERSION/lib:$LD_RUN_PATH" $*; then
      echo 'compilation successful' >&4
    fi 2>&1 1>&3 | grep -v ' linking not done' 1>&2
  ) 4>/dev/null 4>&1 | grep 'compilation successful' >/dev/null
) 3>/dev/null 3>&1


Hopefully *does* libtool already look at LD_RUN_PATH, I didn't
check that -- would libtool also work when I set CXX to
CXX="/usr/local/gcc-3.2/bin/g++ -Wl,-rpath,/usr/local/gcc-3.2/lib"?
If that is the case then I take back my "only libtool can fuck up like that" :p.
Nevertheless, a more robust functioning of libtool would not depend
on the assumption that CXX is a plain compiler executable that behaves
like g++.  It could try to link with a found library and then use
'ldd' to find the path of the library was linked with... but also
that is not waterproof as it depends on LD_LIBRARY_PATH which doesn't
have to be set yet.

I suppose that libtool tries to support all compilers out there...
but if the compiler is a g++, then the output of -v while trying to
link gives enough information in principle.  For example:

>g++-3.2  -L../../.libs -Wl,-rpath -Wl,../../.libs -lecc -lgmpxx  irreducible.o 
>-o irreducible -v
Reading specs from /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
Configured with: /usr/src/gcc/gcc-3.2/configure --prefix=/usr/local/gcc-3.2 
--enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ 
--enable-debug --enable-threads
Thread model: posix
gcc version 3.2
 /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/collect2 -m elf_i386 
-dynamic-linker /lib/ld-linux.so.2 -o irreducible /usr/lib/crt1.o 
/usr/lib/crti.o /usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/crtbegin.o 
-L../../.libs -L/usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2 
-L/usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../.. -rpath 
/usr/local/gcc-3.2/lib: -rpath ../../.libs -lecc -lgmpxx irreducible.o -lstdc++ 
-lm -lgcc_s -lgcc -lc -lgcc_s -lgcc 
/usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/crtend.o /usr/lib/crtn.o

Which includes the phrase 
"-L/usr/local/gcc-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../.."
in the collect2 line.  Actually I think that there is a way to let g++ print 
exactly
which library it is using - but I don't know the options for that, they might 
not
even be documented.

-- 
Carlo Wood <address@hidden>




reply via email to

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