R does not recognize the correct libstdc++.so library - r

When I try to install the kernlab package on R 2.15.2 on Scientific Linux 5.5, I get the following error message:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '~/bin/lib64/R/library/kernlab/libs/kernlab.so':
/usr/java/jdk1.6.0_41/jre/../lib/amd64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ~/bin/lib64/R/library/kernlab/libs/kernlab.so)
R 2.11 is installed on the same system, which installs kernlab just fine. Additionally, the following reports no errors:
ldd -r ~/bin/lib64/R/library/kernlab/libs/kernlab.so
So it seems that R simply doesn't manage to use the right libraries. I set LD_LIBRARY_PATH to /usr/local/gcc-4.6.0/lib64/, which is where the working version of libstdc++.so.6 seems to be, but that did not help.
How can it be that R refuses to use the right libraries? And how can I make it use the correct one?

How can it be that R refuses to use the right libraries?
Something else in the process must be loading the older libstdc++.so before the R shared lib gets loaded. I'm surprised LD_LIBRARY_PATH doesn't help though.

Related

plot KML library load fail, unable to load shared object

Not sure if relevant, but I'm getting this error after a recent update to Mac OS Monterey Version 12.5.1.
After trying library(plotKML) I get the following:
Error: package or namespace load failed for ‘plotKML’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/kchalkowski/Library/R/x86_64/4.1/library/lwgeom/libs/lwgeom.so':
dlopen(/Users/kchalkowski/Library/R/x86_64/4.1/library/lwgeom/libs/lwgeom.so, 0x0006): Library not loaded: '/usr/local/opt/proj/lib/libproj.22.dylib'
I checked the directory /usr/local/opt/proj/lib and sure enough, libproj.22.dylib is not there. Rather, another version is there in it's place: libproj.25.dylib.
Is there a way to get that older version of libproj? or a way to link plotKML to the correct dylib? I had a similar issue with sf, but was able to fix it with a brew reinstall of pkg-config gdal proj geos in the terminal, and uninstalling and reinstalling sf. I've tried uninstalling and reinstalling plotKML but to no avail.
Did a search for the name of the dynamic library and I think I actually just fixed it following advice here: https://github.com/flow-project/flow/issues/896
I used the following in the terminal but instead of 19/5, I replaced the versions of the libraries in the code here with the one I have (25) and the one plotKML wants (22), and it seems to be working now?:
ln -s /usr/local/opt/proj/lib/libproj.19.dylib /usr/local/opt/proj/lib/libproj.15.dylib

R: install uroot package in ubuntu

I am trying to install the forecast package which depends on uroot, which apparently have been written to require a GPU?
install.packages("uroot") yields the following error. Has anyone found this issue and may suggest a work around? I am using ubuntu 16.04.
I have the file in question located here: /usr/local/cuda-8.0/ and I added to my path export PATH=/usr/local/cuda-8.0/:$PATH
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/rstudio2/R/x86_64-pc-linux-gnu-library/3.2/uroot/libs/uroot.so':
libcudart.so.8.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/rstudio2/R/x86_64-pc-linux-gnu-library/3.2/uroot’
Warning in install.packages :
installation of package ‘uroot’ had non-zero exit status
Just in case this is useful for someone, I stumbled with the same problem trying to install "imputeTS" with R version 3.5.1 on Fedora 27 with CUDA 10.0 correctly installed an setted in PATH.
for me it just happened that I was running install.package("imputeTS") (which depends on forecast) in a R console as root, installing the packages to the user home solved the problem. It's seems that the libraries are searched in different places according to the user running the script, it's important to note that.
I just migrated to Linux. On an Ubuntu 18.04 setup, using install.packages with dependencies set to TRUE succeeded with no complaints. (No GPU on mu box.)
install.packages("forecast", dep=TRUE)
# there are quite a few dependencies and you happened to be missing one
packageDescription()
#-----------includes this line----------
Imports: colorspace, fracdiff, ggplot2 (>= 2.2.1), graphics, lmtest,
magrittr, nnet, parallel, Rcpp (>= 0.11.0), stats,
timeDate, tseries, urca, uroot, zoo
You can try to modify file "/etc/rstudio/rserver.conf", add "LD_LIBRARY_PATH" env, like:
rsession-ld-library-path=/usr/local/cuda/lib64
Actually, When you open session of "RStudio Server" from browser, the session does't get env from the ".bashrc".

NLoptr failed to install on Mac: unable to load shared object

I'm trying to install the package nloptr on Mac OS High Sierra in order to use many nice packages like lme4, and I'm using RStudio inside Anaconda, with R 3.4.2. I have also installed NLopt (downloaded from the NLopt website, not the development version. I have also installed Xcode command line tool. But I still can't install nloptr, and get this
Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so':
dlopen(/Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so, 6): Symbol not found: _nlopt_add_equality_mconstraint
Referenced from: /Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so
Expected in: flat namespace
in /Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so
I already searched online for what to do, and did add the path where NLopt was installed to LD_LIBRARY_PATH in the /etc/ldpaths file, but I still get the same error. Yes, I have the same problem as in Trouble installing nloptr package on R 3.3.0, but I didn't find a solution that works there since the person who asked that question resolved it himself and I don't know what he meant when he said "installed as a root". Can anyone help?
Also, I got something like this when installing NLopt with CMake, and this happened to many different functions:
In file included from f77api.c:103:
./f77funcs.h:57:14: warning: 'nlopt_minimize_constrained' is deprecated
[-Wdeprecated-declarations]
*info = nlopt_minimize_constrained((nlopt_algorithm) *algorithm,
^
./nlopt.h:348:35: note: 'nlopt_minimize_constrained' has been explicitly marked
deprecated here
int maxeval, double maxtime) NLOPT_DEPRECATED;
^
./nlopt.h:320:43: note: expanded from macro 'NLOPT_DEPRECATED'
# define NLOPT_DEPRECATED __attribute__((deprecated))
^
Would this be why the library isn't loaded?
BTW, I have installed Rcpp and updated it. Rcpp works on my computer.
Update: I changed the default C and C++ compiler to clang4 downloaded from R project. I tried the installation again, and got a different error:
Error: package or namespace load failed for ‘nloptr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so':
dlopen(/Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so, 6): Library not loaded: #rpath/libnlopt.0.dylib
Referenced from: /Users/lambda/anaconda3/lib/R/library/nloptr/libs/nloptr.so
Reason: image not found
Error: loading failed
I have tried to tell R where the library is by Sys.geteng(DYLD_LIBRARY_PATH = "/usr/local/lib"), but it didn't work. It actually appears that R does know where the shared library is, according to the messages I got from installation, but it just can't load it. Please help!
Never mind, I reinstalled Anaconda, and installed the standalone R and RStudio (not within Anaconda), and those packages all installed successfully. Maybe it's a bad idea to use the RStudio inside Anaconda.
Edit: For those who run into similar scenarios: I switched to Microsoft R Open (MRO), since I'm dealing a lot with linear algebra recently. Then when I tried to install nloptr in MRO, I got a similar error message that shared library failed to load because image not found. I reinstalled the CRAN R 3.4.3 and nloptr installed totally fine there. So I found where nloptr was installed in CRAN R 3.4.3 by .libPaths(), copied the nloptr folder to where MRO stores packages, and used the utility RSwitch to change the default version of R to MRO. Then I loaded nloptr in MRO, installed packages that depend on it, and used those packages; they worked fine. I don't know what's wrong with MRO that caused the error, but at least this worked.

Installing rjags in R on OSX Mavericks

I am trying to install the package "rjags" in R but am running into the following error:
Loading required package: rjags
Error : .onLoad failed in loadNamespace() for 'rjags', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/rjags.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/rjags.so, 10): Symbol not found: __ZN5RangeC1ERKSt6vectorIiSaIiEES4_
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/rjags.so
Expected in: /usr/local/lib/libjags.3.dylib
in /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/rjags.so
Error: package ‘rjags’ could not be loaded
I've installed JAGS on my Mac (running Mavericks), and I am running R-3.1.2. I've tried installing from the url using the devtools package, as recommended by this site:
install_url("http://sourceforge.net/projects/mcmc-jags/files/rjags/3/rjags_3-2.tar.gz",
args="--configure-args='--with-jags-include=/Users/casallas/homebrew/opt/jags/include/JAGS
--with-jags-lib=/Users/casallas/homebrew/opt/jags/lib'
"
)
I've also gone through the instructions on this other site , trying the different versions of JAGS and receive the same error. I'm at a loss for what to try next and am sure the solution is simple. Does anyone have any insights? Thanks so much!
I found that while I was unable to install rjags from the url, if I installed the package from source on my computer I was successful. I did this by downloading the appropriate package from here (which for me was rjags_3-14.tgz) and ran the following command:
install.packages(path_to_file, repos = NULL, type="source")
The error:
Symbol not found: __ZN5RangeC1ERKSt6vectorIiSaIiEES4_
Is (nearly) always caused by a mismatch between standard libraries between the Mavericks build of R (actually rjags) and Snow Leopard build of JAGS (or vice versa). For more info see the instructions at https://sourceforge.net/projects/mcmc-jags/files/JAGS/3.x/Mac%20OS%20X/
I'm guessing that compiling the package yourself from source worked because it matched the version of the standard library that JAGS is using, but this will no longer match the version that R is using (although I'm not sure if this is a major problem, it is not recommended). You would be better to match the builds of R and JAGS and use the pre-built rjags library from CRAN.
It is interesting that you say you have tried both builds of JAGS but I suggest trying again along these lines:
1) Use .Platform$pkgType in R to confirm if it you are using mac.binary (SL) or mac.binary.mavericks (Mavericks) - or failing that re-install the Mavericks binary of R from CRAN
2) Exit R
3) Re-install the appropriate version of JAGS
4) Re-open R and re-install the rjags library from CRAN
5) Try library(rjags)
If this doesn't work can you provide more information so I can try and track down a possible problem with the JAGS builds?
Thanks,
Matt

Problems installing rjags and JAGS on Mac OsX 10.5.8

I am having issues getting rjags the R package for R to call JAGS (Just Another Gibbs Sampler http://www-ice.iarc.fr/~martyn/software/jags/ ).
I am running Mac Os X. 10.5.8 Leopard and using R64 2.12.1. I compiled JAGS from the command line. Then I installed rjags in the R command line.
install.packages(rjags)
When I try to call rjags within R, I get the following error.
> library(rjags)
Error : .onLoad failed in loadNamespace() for 'rjags', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/2.12/Resources /library/rjags/libs/x86_64/rjags.so':
dlopen(/Library/Frameworks/R.framework/Versions/2.12/Resources/library/rjags/libs/x86_64/rjags.so, 10): Library not loaded: /usr/local/lib/libjags.2.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/2.12/Resources/library/rjags/libs/x86_64/rjags.so
Reason: no suitable image found. Did find:
/usr/local/lib/libjags.2.dylib: mach-o, but wrong architecture
/usr/local/lib/libjags.2.dylib: mach-o, but wrong architecture
Error: package/namespace load failed for 'rjags'
I am guessing there is some issue with rjags referencing an unknown file in the library, but I am not sure. I am a fairly novice at the command line and messing around with directories, so any help would be much appreciated.
I found (after downloading and installing the dmg from SourceForge) that the following commands worked for me:
wget http://cran.r-project.org/src/contrib/rjags_2.2.0-4.tar.gz
wget http://cran.r-project.org/src/contrib/R2jags_0.02-15.tar.gz
sudo R --with-jags-modules=/usr/local/lib/JAGS/modules-2.2.0 CMD INSTALL rjags_2.2.0-4.tar.gz
sudo R --with-jags-modules=/usr/local/lib/JAGS/modules-2.2.0 CMD INSTALL R2jags_0.02-15.tar.gz
sudo R --with-jags-modules=/usr/local/lib/JAGS/modules-2.2.0 --arch=i386 CMD INSTALL rjags_2.2.0-4.tar.gz
sudo R --with-jags-modules=/usr/local/lib/JAGS/modules-2.2.0 --arch=x86_64 CMD INSTALL rjags_2.2.0-4.tar.gz
They certainly aren't all necessary, but they were sufficient!
I had the same problem while running Rstudio 0.97.237 and R 2.15.2. The issue had something to do with JAGS.
The fix: Update to JAGS 3-3 by downloading and installing it from here.
I encountered the error: unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so': on my Mac and DuckDuckGo led me to this post. I was using R from the command line, so I can't speak to how it works with RStudio although I'm pretty sure it's the fix for that too. I updated JAGS from the SourceForge link provided in another answer. I can at least verify that it worked for me, though the developer was unsigned (I needed to ignore a MacOS warning during the installation procedure).

Resources