Followers

Thursday, November 5, 2015

Installing R packages that use shared library in Linux

Many R packages use scripts (or libraries) written in other languages like C, FORTRAN etc from shared libraries. Normally the main scripts (and their dependencies like header files(.h files)) are kept in the src directory inside the package. During installation of the package from the source file(.gz) using R CMD INSTALL somepackage.tar.gzthe scripts are compiled and generates some shared objects in the local directory which dynamically links to the shared library (to libsomename.so.some_number file) which is generally /usr/local/lib. This linking happens through some configuration file (/etc/ld.so.conf ) and some environment variables (e.g. LD_LIBRARY_PATH). Often the conf file and the environment variable does not contain the path of the shared library (mostly happens when users use their own shared library instead of the default) and thus during installation it shows the error:  "shared object not found.... no such file or directory".

one way to solve this problem is problem is to run the ldconfig (or /sbin/ldconfig) commands(preferably in verbose mode(-v) ).  This program creates the required links and cache to the most recent shared libraries.

example:

I faced similar type of error "shared object not found.... no such file or directory" during installation of the package fftwtools (R CMD INSTALL fftwtools.tar.gz). The steps I followed to fix the problem are:

1. error obsereved : can not open .../fftwtools/src/fftwtools.so: ... libfftw3.so.3...  no such file or directory.

2. located the file using:  locate libfftw3.so.3 (to be sure that the file exists)
output: 

/usr/local/lib/libfftw3.so.3

/usr/local/lib/libfftw3.so.3.3.2


3. run /sbin/ldconfig -v
output:

/sbin/ldconfig: Path `/lib64' given more than once

/sbin/ldconfig: Path `/usr/lib64' given more than once

........................
/opt/bio/EMBOSS/lib:
        libajax.so.6 -> libajax.so.6.0.3
        libnucleus.so.6 -> libnucleus.so.6.0.3
.................
/lib:
        libdevmapper-event.so.1.02 -> libdevmapper-event.so.1.02
        libiw.so.28 -> libiw.so.28
.......................
/lib64:
        libdevmapper-event.so.1.02 -> libdevmapper-event.so.1.02
        libiw.so.28 -> libiw.so.28
.........................
/usr/local/lib:
        libnucleus.so.6 -> libnucleus.so.6.0.5
        libeplplot.so.3 -> libeplplot.so.3.2.7
.........
        libfftw3.so.3 -> libfftw3.so.3.3.2
        libezlib.so.1 -> libezlib.so.1.1.0
.........................
4. Install the package:  R CMD INSTALL fftwtools.tar.gz


Hope the steps works for you. I will be happy to answer any queries regarding this issue. Thanks a lot for reading the post.

3 comments: