Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation on R 4.1.0 fails #14

Closed
kelbstf opened this issue Jul 28, 2021 · 5 comments
Closed

Compilation on R 4.1.0 fails #14

kelbstf opened this issue Jul 28, 2021 · 5 comments

Comments

@kelbstf
Copy link

kelbstf commented Jul 28, 2021

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
Copy link
Author

kelbstf commented Jul 28, 2021

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
Copy link
Owner

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
Copy link
Author

kelbstf commented Jul 29, 2021

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
Copy link
Owner

RobinHankin commented Jul 29, 2021 via email

@kelbstf
Copy link
Author

kelbstf commented Jul 30, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants