[R-pkg-devel] How does one install a libtool generated libfoo.so.1 file into ./libs/?

Pariksheet Nanda p@r|k@heet@n@nd@ @end|ng |rom uconn@edu
Tue Oct 19 08:16:41 CEST 2021


Hi folks,

On 10/18/21 11:13 PM, Pariksheet Nanda wrote:
> 
> The trouble is, R's installation process will only copy compiled files 
> from ./libs/ that have exactly the extension ".so" and files ending with 
> ".so.1" are ignored.
--snip--
> So is there some mechanism to copy arbitrary files or symlinks to the 
> final install location?  I prefer not to patch upstreams Makefile.am to 
> remove their -version-info, but currently that's the only option I can 
> think of.

It turns out removing -version-info or setting it to 0.0.0 will still 
try to link against libghmm.so.0 which is still problematic.  I don't 
see how to disable libtool's versioning.

So after playing around, the only way I can think of doing is is 
eliminating the dependency file by compiling it statically and linking 
it with the dynamic library, because when I try merging the 2 dynamic 
libraries with libtool it gives the same error of not finding 
"libghmm.so.1".  I have a patch that works on my Debian machines, but 
not yet on the Ubuntu CI Image:

https://gitlab.com/coregenomics/tsshmm/-/commit/e9608f01deb7baa13684d2bd65fe11e93f6c2e08

Also pasting the short diff below for search-ability.


> Pariksheet

Pariksheet



$ GIT_PAGER=cat git log -1 --patch
commit e9608f01deb7baa13684d2bd65fe11e93f6c2e08 (HEAD -> master, 
origin/master, origin/HEAD)
Author: Pariksheet Nanda <pariksheet.nanda using uconn.edu>
Date:   Tue Oct 19 01:43:09 2021 -0400

     BLD: Link bundled dependency statically to workaround load errors

diff --git a/configure.ac b/configure.ac
index 87b4d31..4d0be6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,8 +135,6 @@ AS_IF([test x$with_ghmm_strategy = x],
        ) # AS_IF
  ) # AS_IF

-AC_SUBST(GHMM_LIBS, -lghmm)
-
  # If GHMM_ROOT was provided, set the header and library paths.
  #
  # Check for the existance of include/ and lib/ sub-directories and if 
both are
@@ -180,7 +178,10 @@ AS_IF(test x$found_ghmm_system != xyes &&
        AM_CONDITIONAL(BUNDLED_GHMM, true)
        [AX_SUBDIRS_CONFIGURE([src/ghmm-0.9-rc3],
                              [[CFLAGS=$CFLAGS],
-                             [--enable-gsl=no],
+                             [--enable-static],
+                             [--disable-shared],
+                             [--with-pic],
+                             [--enable-gsl=no],
                               [--disable-gsltest],
                               [--with-rng=mt],
                               [--with-python=no],
@@ -191,8 +192,14 @@ AS_IF(test x$found_ghmm_system != xyes &&
        [AS_IF([test -d $GHMM_ROOT], [],
               AC_MSG_FAILURE(Directory of bundled GHMM not found.))]
        [AC_SUBST(GHMM_CPPFLAGS, ["-I$GHMM_ROOT/.."])]
-      # Using -rpath=. prefers the bundled over any system installation.
-      [AC_SUBST(GHMM_LDFLAGS, ["-Wl,-rpath=. -L$GHMM_ROOT/.libs"])]
+      # We don't need GMM_LIBS or GHMM_LDFLAGS because we can directly 
merge
+      # libraries using tsshmm_la_LIBADD per
+      # https://stackoverflow.com/a/13978856 and
+      # 
https://www.gnu.org/software/automake/manual/html_node/Libtool-Convenience-Libraries.html
+      #
+      # However we now need to link against libghmm's libxml2 dependency
+      # because we're merging libraries.
+      [PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6])]
        AC_MSG_NOTICE(Applying patches to GHMM to fix errors and 
warnings from "R CMD check")
        # Patch bug in upstream's configure bug:
        #
@@ -239,7 +246,9 @@ AS_IF(test x$found_ghmm_system != xyes &&
  #include <ghmm/fbgibbs.h>' src/ghmm-0.9-rc3/tests/mcmc.c
        [touch -r src/ghmm-0.9-rc3/tests/mcmc.c{.bak,}]
        [diff -u src/ghmm-0.9-rc3/tests/mcmc.c{.bak,}]
-      AC_MSG_NOTICE(Finished patching GHMM)
+      AC_MSG_NOTICE(Finished patching GHMM),
+      # Only link if we're not using the static bundled dependency.
+      [AC_SUBST(GHMM_LIBS, -lghmm)]
  ) # AS_IF

  # Variables for Doxygen.
diff --git a/src/Makefile.am b/src/Makefile.am
index 617a4e7..0e38b4a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,18 +9,19 @@ endif
  lib_LTLIBRARIES    = tsshmm.la
  tsshmm_la_CFLAGS   = $(PKG_CFLAGS)
  tsshmm_la_CPPFLAGS = $(PKG_CPPFLAGS)
+if BUNDLED_GHMM
+tsshmm_la_LIBADD   = @GHMM_ROOT@/libghmm.la
+tsshmm_la_LDFLAGS  = -module $(PKG_LIBS) @LIBXML2_LIBS@
+else
  tsshmm_la_LDFLAGS  = -module $(PKG_LIBS)
+endif
  tsshmm_la_SOURCES  = R_init_tsshmm.c R_wrap_tsshmm.c models.c \
  simulate.c train.c tss.c viterbi.c

  ACLOCAL_AMFLAGS = -I tools

  # Hook that runs after the default "all" rule.
-if BUNDLED_GHMM
-all-local : tsshmm.so libghmm.so
-else
  all-local : tsshmm.so
-endif

  # One of the limitations with POSIX-compliant `make` is not being able to
  # specify multiple outputs from a single rule.  Therefore, even though 
libtool
@@ -30,14 +31,8 @@ tsshmm.so : tsshmm.la
  	cp -av .libs/tsshmm.so.0.0.0 $@
  	chmod -x $@

-if BUNDLED_GHMM
-libghmm.so : @GHMM_ROOT@/libghmm.la
-	cp -av @GHMM_ROOT@/.libs/libghmm.so.1.0.0 $@
-	chmod -x $@
-endif
-
  clean-local :
-	rm -f tsshmm.so libghmm.so
+	rm -f tsshmm.so

  distclean-local : clean-local



More information about the R-package-devel mailing list