rgsl

R DirichletMultinomial package - libgsl.so.27: cannot open shared object file: No such file or directory


I'm having problems installing DirichletMultinomial R package. The main issue being, R does not recognize libgsl.so.27, which is in my /usr/local/lib directory:

$ ls -lh /usr/local/lib
total 46M
-rw-r--r-- 1 root root  27M Apr 29 11:30 libgsl.a
-rw-r--r-- 1 root root 2.2M Apr 29 11:30 libgslcblas.a
-rwxr-xr-x 1 root root  948 Apr 29 11:30 libgslcblas.la*
lrwxrwxrwx 1 root root   20 Apr 29 11:30 libgslcblas.so -> libgslcblas.so.0.0.0*
lrwxrwxrwx 1 root root   20 Apr 29 11:30 libgslcblas.so.0 -> libgslcblas.so.0.0.0*
-rwxr-xr-x 1 root root 1.3M Apr 29 11:30 libgslcblas.so.0.0.0*
-rwxr-xr-x 1 root root  917 Apr 29 11:30 libgsl.la*
lrwxrwxrwx 1 root root   16 Apr 29 11:30 libgsl.so -> libgsl.so.27.0.0*
lrwxrwxrwx 1 root root   16 Apr 29 11:30 libgsl.so.27 -> libgsl.so.27.0.0*
-rwxr-xr-x 1 root root  16M Apr 29 11:30 libgsl.so.27.0.0*
drwxr-xr-x 2 root root   20 Apr 29 11:30 pkgconfig/

Whenever I try to install the package,I get this error:

gcc -shared -L/HL8/HApp/R/4.3.3/lib64/R/lib -L/usr/local/lib64 -o DirichletMultinomial.so R_init_DirichletMultinomial.o dirichlet_fit.o dirichlet_fit_main.o -L/usr/local/lib -lgsl -lgslcblas -lm -L/HL8/HApp/R/4.3.3/lib64/R/lib -lR
installing to /home/username/R/x86_64-pc-linux-gnu-library/4.3/00LOCK-DirichletMultinomial/00new/DirichletMultinomial/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘DirichletMultinomial’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/nsk980613/R/x86_64-pc-linux-gnu-library/4.3/00LOCK-DirichletMultinomial/00new/DirichletMultinomial/libs/DirichletMultinomial.so':
  libgsl.so.27: cannot open shared object file: No such file or directory
Error: loading failed

As I said, I've downloaded gsl, both by using package manager (yum) and by manually installing using the tarball. I've currently erased the yum-installed gsl package as it did not work, and I fear I might break something if I uninstall my manual gsl installation.

I did try updating my LD_LIBRARY PATH: export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib

I've seen similar issues get solved with this, but for me this did not work. I really can't think of reasons as to why it's not working, but if there's one thing I should note is that I'm currently using R on a remote server. Downloading it on my local R worked fine.

Any help or recommendation would be greatly appreciated. Thanks!


Solution

  • I don't have a Rocky Linux machine but here's what you need to install the library onto a Rocky Linux 8.9 Docker image.

    FROM rockylinux:8.9
    
    RUN dnf install -y epel-release
    RUN dnf config-manager --set-enabled powertools
    RUN dnf install -y R gsl-devel
    
    RUN R -e 'install.packages("BiocManager", repos="https://cloud.r-project.org")'
    RUN R -e 'BiocManager::install("DirichletMultinomial", ask = FALSE)'
    RUN R -e 'library(DirichletMultinomial)'
    

    Have you followed these steps on your machine?

    When I checked on the location of libgsl.so I found that it was in /usr/lib64 (not /usr/local/lib).

    # find / -name libgsl.so
    /usr/lib64/libgsl.so
    

    If instead you install GSL from source then this is what you need to do:

    wget https://ftp.gnu.org/gnu/gsl/gsl-2.7.1.tar.gz
    cd gsl-2.7.1
    ./configure --prefix=/usr
    make
    sudo make install
    

    Then confirm that all files are present:

    find /usr/lib -name "libgsl*"
    

    That should produce the following output (pretty much precisely!):

    /usr/lib/libgslcblas.so.0.0.0
    /usr/lib/libgsl.so.27
    /usr/lib/libgslcblas.so
    /usr/lib/libgsl.so.27.0.0
    /usr/lib/libgslcblas.la
    /usr/lib/x86_64-linux-gnu/libgslcblas.so.0.0.0
    /usr/lib/x86_64-linux-gnu/libgsl.so.27
    /usr/lib/x86_64-linux-gnu/libgsl.so.27.0.0
    /usr/lib/x86_64-linux-gnu/libgslcblas.so.0
    /usr/lib/libgslcblas.a
    /usr/lib/libgsl.a
    /usr/lib/libgslcblas.so.0
    /usr/lib/libgsl.la
    /usr/lib/libgsl.so
    

    Start R and install the required package.