Subject: bug#9728: Incorrect -L flags order for HP-UX

From: Peter O'Gorman <[email-masked]>
Date: Wed, 12 Oct 2011 21:52:36 -0500

On 10/11/2011 08:58 AM, Vincent Lefevre wrote:
> With libtool 2.4 and automake 1.11.1, we have the following problem
> for MPFR 3.1.0. We have received a bug report saying that when the
> tests are run on a HP-UX machine, the following command is run:
>
> libtool: link: gcc -O2 -s -o tversion tversion.o  -L/opt/gnu/lib ./.libs/libfrtests.a -lm -L../src/.libs -lmpfr -lgmp -Wl,+b -Wl,/xxx/gnu/mpfr-3.1.0/objdir/src/.libs:/opt/gnu/lib
>
> The problem is that -L../src/.libs comes after -L/opt/gnu/lib, so that
> linking is done against the MPFR version installed in /opt/gnu/lib
> instead of the one from ../src/.libs, which has just been compiled.

Hi Vincent,

Unfortunately this is a fairly common problem.

If the flags were added by the user, they could set LIBS=-L/opt/gnu/lib 
instead on some platfroms, but that won't work on HP-UX either because 
its linker is rather strict that -L flags for paths that contain the 
library be ordered before the -l flag for that library.

Anyway, the problem can be avoided by not putting the -L and -l flags 
for gmp in LDFLAGS and LIBS, instead put both in e.g. GMP_LIBS, 
(GMP_LIBS="-L/opt/gnu/lib -lgmp"), then add $(GMP_LIBS) to LDADD.

Peter