Subject: libtool always outputs "libxml2.la seems to be moved" when making a C++ library

From: Jan Engelhardt <[email-masked]>
Date: Sat, 18 Apr 2015 11:48:10 +0200 (CEST)

Observed in libtool-2.4.2:

libtool warns about moved paths, yet, libtool was the one that added
the compiler-specific
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64 into the
command line in the first place.

/bin/sh ./libtool  --tag=CXX   --mode=link g++  -g -O2   -o libx.la -rpath /usr/local/lib x.lo -lxml2 
libtool: link: g++  -fPIC -DPIC -shared -nostdlib /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.8/crtbeginS.o  .libs/x.o   -Wl,-rpath -Wl,/usr/lib64 -Wl,-rpath -Wl,/usr/lib64 /usr/lib64/libxml2.so -ldl -lz -llzma -L/usr/lib64/gcc/x86_64-suse-linux/4.8 -L/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.8/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib64/gcc/x86_64-suse-linux/4.8/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crtn.o  -O2   -Wl,-soname -Wl,libx.so.0 -o .libs/libx.so.0.0.0
libtool: link: (cd ".libs" && rm -f "libx.so.0" && ln -s "libx.so.0.0.0" "libx.so.0")
libtool: link: (cd ".libs" && rm -f "libx.so" && ln -s "libx.so.0.0.0" "libx.so")
libtool: link: ( cd ".libs" && rm -f "libx.la" && ln -s "../libx.la" "libx.la" )
/bin/sh ./libtool  --tag=CXX   --mode=link g++  -g -O2   -o liby.la -rpath /usr/local/lib x.lo libx.la 
libtool: link: warning: `/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/libxml2.la' seems to be moved

What was expected instead:
Perhaps not use -nostdlib -L/usr/lib64/... and just let CXXLD do that itself
internally.

--- configure.ac
AC_INIT([f],[0])
AM_INIT_AUTOMAKE([foreign])
LT_INIT
AC_PROG_CXX
AC_OUTPUT([Makefile])
---

--- Makefile.am
lib_LTLIBRARIES = libx.la liby.la
libx_la_SOURCES = x.cpp
libx_la_LIBADD = -lxml2
liby_la_SOURCES = x.cpp
liby_la_LIBADD = libx.la
---

--- x.cpp
// empty
---

--- /usr/lib64/libxml2.la
# libxml2.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4.2
#
# Please DO NOT delete this file!
# It is necessary for linking the library.

# The name that we can dlopen(3).
dlname='libxml2.so.2'

# Names of this library.
library_names='libxml2.so.2.9.1 libxml2.so.2 libxml2.so'

# The name of the static archive.
old_library=''

# Linker flags that can not go in dependency_libs.
inherited_linker_flags=''

# Libraries that this one depends upon.
dependency_libs=' -ldl -lz -llzma -lm'

# Names of additional weak libraries provided by this library
weak_library_names=''

# Version information for libxml2.
current=11
age=9
revision=1

# Is this an already installed library?
installed=yes

# Should we warn about portability when linking against -modules?
shouldnotlink=no

# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''

# Directory that this library needs to be installed in:
libdir='/usr/lib64'
---