RobinHankin / gsl

an R wrapper for the Gnu Scientific Library
15 stars 9 forks source link

Compilation on R 4.1.0 fails #14

Closed kelbstf closed 1 year ago

kelbstf commented 3 years ago

Hello,

i fail to install "gsl" in R 4.1.0 from CRAN on a CentOS7.8 with gsl 2.7 compiled from sources:

> install.packages('gsl')

...

** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘gsl’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/R/4.1.0/lib/R/library/00LOCK-gsl/00new/gsl/libs/gsl.so':
  libgslcblas.so.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed

The strange thing is that the actual compilation seems to work perfectly fine:

configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c airy.c -o airy.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c bessel.c -o bessel.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c clausen.c -o clausen.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c coulomb.c -o coulomb.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c coupling.c -o coupling.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c dawson.c -o dawson.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c debye.c -o debye.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c dilog.c -o dilog.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c ellint.c -o ellint.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c elljac.c -o elljac.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c error.c -o error.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c expint.c -o expint.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c fermi_dirac.c -o fermi_dirac.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c gamma.c -o gamma.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c gegenbauer.c -o gegenbauer.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c hyperg.c -o hyperg.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c init.c -o init.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c laguerre.c -o laguerre.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c lambert.c -o lambert.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c legendre.c -o legendre.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c log.c -o log.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c poly.c -o poly.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c pow_int.c -o pow_int.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c psi.c -o psi.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c qrng.c -o qrng.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c rng.c -o rng.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c synchrotron.c -o synchrotron.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c transport.c -o transport.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c trig.c -o trig.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c vector.c -o vector.o
gcc -std=gnu99 -I"/opt/R/4.1.0/lib/R/include" -DNDEBUG -I/opt/gsl-2.7/include -I.  -I/usr/local/include   -fpic  -g -O2  -c zeta.c -o zeta.o
gcc -std=gnu99 -shared -L/opt/R/4.1.0/lib/R/lib -L/usr/local/lib -o gsl.so airy.o bessel.o clausen.o coulomb.o coupling.o dawson.o debye.o dilog.o ellint.o elljac.o error.o expint.o fermi_dirac.o gamma.o gegenbauer.o hyperg.o init.o laguerre.o lambert.o legendre.o log.o poly.o pow_int.o psi.o qrng.o rng.o synchrotron.o transport.o trig.o vector.o zeta.o -L/opt/gsl-2.7/lib -lgsl -lgslcblas -lm -L/opt/R/4.1.0/lib/R/lib -lR
installing to /opt/R/4.1.0/lib/R/library/00LOCK-gsl/00new/gsl/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package ‘gsl’
    finding HTML links ... done
    Airy                                    html  
    Bessel                                  html  
    Clausen                                 html  
    Coulomb                                 html  
    Coupling                                html  
    Dawson                                  html  
    Debye                                   html  
    Dilog                                   html  
    Ellint                                  html  
    Elljac                                  html  
    Error                                   html  
    Expint                                  html  
    Fermi-Dirac                             html  
    Gamma                                   html  
    Gegenbauer                              html  
    Hyperg                                  html  
    Laguerre                                html  
    Lambert                                 html  
    Legendre                                html  
    Log                                     html  
    Misc                                    html  
    Multimin                                html  
    Poly                                    html  
    Pow_int                                 html  
    Psi                                     html  
    Qrng                                    html  
    Rng                                     html  
    Synchrotron                             html  
    Transport                               html  
    Trig                                    html  
    Zeta                                    html  
    gsl-deprecated                          html  
    gsl-package                             html  
** building package indices
** installing vignettes

Session:

> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.3.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.1.0

Just the access to the result fails. And i see no reason, because:

> Sys.getenv("PATH")
[1] "/opt/R/4.1.0/bin: ... /opt/gsl-2.7/bin:/root/go/bin:/root/bin"

The old gsl 1.0 had been removed prior to compiling 2.7, so there is only one instance around... Does any one have an idea?

kelbstf commented 3 years ago

Hello,

i just wanted to add that the following attempt to nail the library path did not improve the situation:

> Sys.getenv("LD_LIBRARY_PATH")
[1] "/usr/lib64/R/lib:/usr/lib/jvm/jre/lib/amd64/server:/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/java/lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib/:/opt/hdf5-1.12.0/lib"
> dyn.load("/opt/gsl-2.7/lib/libgsl.so")

And an additional attempt:

> Sys.setenv(LD_LIBRARY_PATH=paste("/opt/gsl-2.7/lib/", Sys.getenv("LD_LIBRARY_PATH"),sep=":"))
> Sys.getenv("LD_LIBRARY_PATH")
[1] "/opt/gsl-2.7/lib/:/opt/hdf5-1.12.0/lib:/usr/lib64/R/lib:/usr/lib/jvm/jre/lib/amd64/server:/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/java/lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib/:/opt/hdf5-1.12.0/lib"
> 

It looks like the path is known and used at compile time, but missing at launch time?

Best

RobinHankin commented 3 years ago

Hi there, thanks for this comprehensive post. I have had similar reports from other CentOS users, a system I am not familiar with. Not sure if R-devel or R-help would be appropriate here, it looks (as you say) to be a centos issue. If you resolve the issue, please let me know and I'll add it to the readme. Maybe remove /opt/R/4.1.0/lib/R/library/00LOCK-gsl/ ?

Best wishes, Robin

kelbstf commented 3 years ago

Hello Robin,

thank you for your quick response and for your information about what you hear from your CentOS users. That pointed me to considering dynamic linker run-time bindings, which non-CentOS systems may not have to, as their os already ships with a proper release level. Because i had to compile it from scratch, i had opportunity to miss updating the dynamic linker run-time bindings afterwards ;-) After having caught up on that, the compilatin of GSL succeeded. That also explains why apparently the compilation succeeded, but the run time access during the test phase failed.

So from my perspective, this issue could be closed.

Best wishes

RobinHankin commented 3 years ago

thanks for letting me know. Would you be able to send me a couple of sentences describing the problem and solution in a form suitable for adding to the README?

best wishes

Robin @.***>

On Fri, Jul 30, 2021 at 12:35 AM kelbstf @.***> wrote:

Hello Robin,

thank you for your quick response and for your information about what you hear from your CentOS users. That pointed me to considering dynamic linker run-time bindings, which non-CentOS systems may not have to, as their os already ships with a proper release level. Because i had to compile it from scratch, i had opportunity to miss updating the dynamic linker run-time bindings afterwards ;-) After having caught up on that, the compilatin of GSL succeeded. That also explains why apparently the compilation succeeded, but the run time access during the test phase failed.

So from my perspective, this issue could be closed.

Best wishes

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RobinHankin/gsl/issues/14#issuecomment-889085215, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFFZUVDLRLJVVYOCJOHN4TT2FDKJANCNFSM5BEDBZVA .

kelbstf commented 3 years ago

Hello Robin,

sorry, i just realise i should have been more detailed to make it useful.

The core reason in my situation was that the stock CentOS7 GSL is too old (1.15-13.el7) for the gsl-wrapper. Therefore i compiled a current release of GSL, but installed into an "uncommon" place, with the intention to have multiple versions around (development server).

./configure --prefix=/opt/gsl-2.7

Since neither the executable of the OS-level GSL nor the GSL wrapper for R are installed in the default PATH (/lib, /usr/lib, ...), and the custom directory seems to be stored in -rpath-link at compile time and apparently not in -rpath for the run time, shared objects are looked up as a last resort in the directories specified by /etc/ld.so.conf. Which i had missed to add after having compiled GSL and before attempting to install(/compile) the "gsl" wrapper in R.

After having fixed that via

vi /etc/ld.so.conf.d/libgsl-x86_64.conf
/opt/gsl-2.7/lib/

installation of the gsl wrapper from CRAN in R with no additional specifications worked immediately via:

install.packages('gsl')

That's at least my understanding of why this worked. I am not sure about the "-rpath" explanation, but it would match the sgnificant behaviour that while the compilation worked, the test call to the resulting executable out of the "/tmp" immediately afterwards failed?

Would that fit your bill?

Best wishes