Bug#310226: [Pkg-octave-devel] Bug#310226: octave2.9: FTBFS: linking a shared lib to a static lib fails.

Rafael Laboissiere Rafael Laboissiere <rafael@debian.org>, 310226@bugs.debian.org, 310226@bugs.debian.org
Tue, 24 May 2005 09:14:59 +0200


--aH/0uqREc1VzwMkO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

[ This is a reply to a bug report filled against the octave2.9 Debian
  package, which depends on glpk.  For further information, please see
  http://bugs.debian.org/310226 ]

* Kurt Roeckx <kurt@roeckx.be> [2005-05-22 16:23]:

> Package: octave2.9
> Version: 2.9.2-2
> Severity: serious
> 
> Hi,
> 
> Your package is failing to build on a few arches (atleast hppa
> and amd64) because when you're creating the shared lib you're
> linking to a static version.  Static version should be compiled
> without -fPIC while shared version must be compiled with it.
> (See policy section 10.2)
> 
> This is giving the following error:
> /usr/bin/g++ -shared -o __glpk__.oct pic/__glpk__.o -L../libcruft -lcruft -L../
> liboctave -loctave -L. -loctinterp -llapack-3 -lblas-3 -lfftw3 -lamd -lumfpack
> -lreadline  -lncurses -ldl -lhdf5 -lz -lm  -L/usr/lib/gcc-lib/x86_64-linux/3.3.
> 6 -L/usr/lib/gcc-lib/x86_64-linux/3.3.6/../../../../lib64 -L/usr/lib/gcc-lib/x8
> 6_64-linux/3.3.6/../../.. -L/lib/../lib64 -L/usr/lib/../lib64 -lhdf5 -lz -lfrtb
> egin -lg2c -lm -lgcc_s -lglpk
> /usr/bin/ld: /usr/lib/gcc-lib/x86_64-linux/3.3.6/../../../../lib64/libglpk.a(gl
> plib2.o): relocation R_X86_64_32 can not be used when making a shared object; r
> ecompile with -fPIC
> /usr/lib/gcc-lib/x86_64-linux/3.3.6/../../../../lib64/libglpk.a: could not read
>  symbols: Bad value
> collect2: ld returned 1 exit status
> 
> There are some solutions for this:
> - Ask the glpk maintainer to provide a shared lib.  This
>   is ussually the prefered solution.
> - Ask the glpk maintainer to provide a special static pic
>   (libglpk-pic.a or something) version and link to that
>   version.  This solution ussually isn't want you want.

This is actually an upstream problem.  It is trivial nowadays to add
Libtool support to a package and have shared libraries available.  I am
attaching below two slim patches for the glpk package which add Libtool
support.  The first patch regards only the upstream files, while the
second is for the Debian specific files.

After applying the patch, the usual "aclocal; libtoolize; automake;
autoconf" must be run, of course.  The built package contains:

$ debc | grep /usr/lib
drwxr-xr-x root/root         0 2005-05-24 08:58:22 ./usr/lib/
-rw-r--r-- root/root    520060 2005-05-24 08:58:22 ./usr/lib/libglpk.so.0.0.0
-rw-r--r-- root/root       802 2005-05-24 08:58:20 ./usr/lib/libglpk.la
-rw-r--r-- root/root    661238 2005-05-24 08:58:22 ./usr/lib/libglpk.a
lrwxrwxrwx root/root         0 2005-05-24 08:58:20 ./usr/lib/libglpk.so.0 ->
libglpk.so.0.0.0
lrwxrwxrwx root/root         0 2005-05-24 08:58:20 ./usr/lib/libglpk.so ->
libglpk.so.0.0.0



Please consider applying this patch either upstream or in the Debian
package.

-- 
Rafael

--aH/0uqREc1VzwMkO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="glpk-libtool-upstream.patch"

diff -Naur glpk-4.8-orig/configure.in glpk-4.8/configure.in
--- glpk-4.8-orig/configure.in	2005-01-12 10:00:00.000000000 +0100
+++ glpk-4.8/configure.in	2005-05-23 17:13:43.000000000 +0200
@@ -9,7 +9,7 @@
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_INSTALL
-AC_PROG_RANLIB
+AC_PROG_LIBTOOL
 
 dnl Checks for libraries.
 AC_CHECK_LIB(m, sqrt)
diff -Naur glpk-4.8-orig/examples/Makefile.am glpk-4.8/examples/Makefile.am
--- glpk-4.8-orig/examples/Makefile.am	2005-01-12 10:00:00.000000000 +0100
+++ glpk-4.8/examples/Makefile.am	2005-05-23 17:19:03.000000000 +0200
@@ -2,7 +2,7 @@
 
 INCLUDES = -I../include
 
-LDADD = ../src/libglpk.a
+LDADD = ../src/libglpk.la
 
 bin_PROGRAMS = glpsol tspsol
 
diff -Naur glpk-4.8-orig/src/Makefile.am glpk-4.8/src/Makefile.am
--- glpk-4.8-orig/src/Makefile.am	2005-01-12 10:00:00.000000000 +0100
+++ glpk-4.8/src/Makefile.am	2005-05-23 17:14:28.000000000 +0200
@@ -2,9 +2,10 @@
 
 INCLUDES = -I../include
 
-lib_LIBRARIES = libglpk.a
-
-libglpk_a_SOURCES = \
+lib_LTLIBRARIES = libglpk.la
+libglpk_la_LDFLAGS = -version-info 0:0:0
+	       
+libglpk_la_SOURCES = \
 glpavl.c \
 glpdmp.c \
 glpiet.c \

--aH/0uqREc1VzwMkO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="glpk-libtool-debian.patch"

diff -Naur glpk-4.8-orig/debian/changelog glpk-4.8/debian/changelog
--- glpk-4.8-orig/debian/changelog	2005-05-23 17:03:11.000000000 +0200
+++ glpk-4.8/debian/changelog	2005-05-23 17:32:39.000000000 +0200
@@ -1,3 +1,9 @@
+glpk (4.8-1.1) unstable; urgency=low
+
+  * Non-maintainer version.  Added Libtool support.
+
+ -- Rafael Laboissiere <rafael@debian.org>  Mon, 23 May 2005 17:32:00 +0200
+
 glpk (4.8-1) unstable; urgency=low
 
   * New upstream release, packaged by Brady Hunsaker
diff -Naur glpk-4.8-orig/debian/rules glpk-4.8/debian/rules
--- glpk-4.8-orig/debian/rules	2005-05-23 17:03:11.000000000 +0200
+++ glpk-4.8/debian/rules	2005-05-24 08:57:13.777987808 +0200
@@ -73,8 +73,9 @@
 	dh_strip
 	dh_compress
 	dh_fixperms
-	dh_installdeb
+	dh_makeshlibs -V
 	dh_shlibdeps
+	dh_installdeb
 	dh_gencontrol
 	dh_md5sums
 	dh_builddeb

--aH/0uqREc1VzwMkO--