R: Error in dyn.load(file, DLLpath = DLLpath, …)

2020-03-02 05:53发布

问题:

I have worked now for some time on an R project in my office's desktop computer, but need to carry the scripts with me while on travel. I copied everything into my laptop and did some changes to the code. Alas, when trying to compile (following the exact same procedure I was using in my desktop computer), the following error:

$ R CMD INSTALL --no-multiarch --with-keep.source coala
* installing to library ‘/home/my_pc/R/x86_64-pc-linux-gnu-library/3.3’
* installing *source* package ‘coala’ ...
** libs
make: Nothing to be done for `all'.
installing to /home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
unable to load shared object '/home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala/libs/coala.so':
/home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala/libs/coala.so: undefined symbol: _ZSt24__throw_out_of_range_fmtPKcz
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala’
* restoring previous ‘/home/my_pc/R/x86_64-pc-linux-gnu-library/3.3/coala’

Both computers have the same Ubuntu but different R version. Also, I have to mention that I am working in two libraries at the same time and that the accompanying library update without problems, which makes this error message more puzzling. I have checked answers that may be related to this question, but can't figure out how to apply their solutions:

R: error installing packages UBUNTU - Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object Got message unable to load shared object stats.so when R starts

Is there a way to solve this problem? Which may be the cause? What is the undefined symbol _ZSt24__throw_out_of_range_fmtPKcz?

回答1:

What is .libPaths() giving you as the output?

I encountered the same problem using the latest update today (R 3.3.1 for MacOS X). My R installation seemed to crash after updating it. My solution was simply to remove the lib directories from the file system and reinstall R:

rm -rf /Users/johann/Library/R/3.3/library
sudo rm -rf Library/Frameworks/R.framework/Versions/3.3/Resources/library

Hope this helps...



回答2:

I had a similar issue with rgdal on Ubuntu. Re-installing the package was enough to getting it working again.

$ sudo R
> install.packages("rgdal")
> quit()
$ exit


回答3:

The problem is the linkage with your g++ stdlib. Different versions of Ubuntu have different versions of g++ stdlib. You cant always copy binaries from one to the other.

You may fix this by recompiling R for the laptop, or using the Ubuntu R packages. e.g. http://packages.ubuntu.com/xenial/r-base



标签: c++ r ubuntu g++