RNetCDF无法打开共享库文件 [英] RNetCDF cannot open shared object file

查看:96
本文介绍了RNetCDF无法打开共享库文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下命令在笔记本电脑(Ubuntu 12.04)上安装RNetCDF软件包

install.packages('RNetCDF',lib='/home/my_computer/RSCRIPTS/R_LIB/',configure.args="--with-netcdf-include='/home/my_computer/bin/libs4cdo-0.0.10/netcdf-4.2/include/' --with-netcdf-lib='/home/my_computer/local/bin' --with-hdf5-lib='/home/my_computer/local/lib/' --with-udunits-include='/usr/local/lib/' --with-udunits-lib='/usr/local/lib/'",repos='http://star-www.st-andrews.ac.uk/cran/')

,但该软件包无法安装.请参阅以下消息:

trying URL 'http://star-www.st-andrews.ac.uk/cran/src/contrib/RNetCDF_1.6.1-2.tar.gz'
Content type 'application/x-gzip' length 70301 bytes (68 Kb)
opened URL
==================================================
downloaded 68 Kb

* installing *source* package ‘RNetCDF’ ...
** package ‘RNetCDF’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking for nc_open in -lnetcdf... yes
checking for utInit in -ludunits2... no
checking for utScan in -ludunits2... yes
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking netcdf.h usability... yes
checking netcdf.h presence... yes
checking for netcdf.h... yes
checking udunits.h usability... yes
checking udunits.h presence... yes
checking for udunits.h... yes
configure: creating ./config.status
config.status: creating R/load.R
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/share/R/include -I/usr/local/lib/ -I/home/bauduinm/bin/libs4cdo-0.0.10/netcdf-4.2/include/      -fpic  -O3 -pipe  -g -c RNetCDF.c -o RNetCDF.o
gcc -std=gnu99 -shared -o RNetCDF.so RNetCDF.o -ludunits2 -lnetcdf -L/home/my_computer/local/lib/ -L/usr/local/lib/ -L/home/my_computer/local/bin -lexpat -L/usr/lib/R/lib -lR
installing to /home/my_computer/RSCRIPTS/R_LIB/RNetCDF/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
 unable to load shared object '/home/my_computer/RSCRIPTS/R_LIB/RNetCDF  /libs/RNetCDF.so':
libexpat.so.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed  
* removing ‘/home/my_computer/RSCRIPTS/R_LIB/RNetCDF’

The downloaded packages are in
‘/tmp/Rtmpl5MniY/downloaded_packages’
Warning message:
In install.packages("RNetCDF", lib = "/home/my_computer/RSCRIPTS/R_LIB/",  :
    installation of package ‘RNetCDF’ had non-zero exit status

当我尝试

sudo R CMD INSTALL --libary='/home/my_computer/RSCRIPTS/R_LIB/' --configure-args="--with-netcdf-include='/home/my_computer/bin/libs4cdo-0.0.10/netcdf-4.2/include/' --with-netcdf-lib='/home/my_computer/local/lib/' --with-hdf5-lib='/home/my_computer/local/lib/' --with-udunits-include=/usr/local/lib/ --with-udunits-lib=/usr/local/lib/" /home/my_computer/Downloads/RNetCDF_1.6.1-2.tar.gz

错误消息替换为

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
unable to load shared object '/usr/local/lib/R/site-library/RNetCDF/libs/RNetCDF.so':
  libnetcdf.so.7: cannot open shared object file: No such file or directory

libnetcdf.so.7肯定在/home/my_computer/local/lib/中,这也是我的LD_LIBRARY_PATH.可以肯定的是,libexpat.so.0是第一个错误消息(带有install.packages)中的文件之一,位于与intel相关的文件夹中,这些文件夹看起来与netcdf库没有任何关系.

有人可以启发我吗?

谢谢.

嗯,我永远不会知道发生了什么,因为三天后当我使用完全相同的install.packages命令行再次尝试安装软件包时,没有任何问题...所以我唯一的建议是同样的问题是注销R并重新开始,以防万一会话中先前的一些错误仍保留在日志中.

解决方案

尝试将--no-test-load添加到R CMD INSTALL,这将避免在安装过程中出现错误.

然后检查是否可以在正常的R会话(使用library(RNetCDF))中加载程序包. 如果由于无法加载共享对象"错误而失败:

  1. 检查R是否将您的$ LD_LIBRARY_PATH与Sys.getenv("LD_LIBRARY_PATH")一起使用
  2. 查看ldd /usr/local/lib/R/site-library/RNetCDF/libs/RNetCDF.so的输出,并查看libnetcdf.so.7是否解析为R的LD_LIBRARY_PATH中包含的路径

顺便说一句,我使用Ubuntu随附的libnetcdf安装RNetCDF没问题(apt-get install libnetcdf-dev [版本4.1.1]);除非您确实需要libnetcdf 4.2版本,否则您可能要尝试一下.

I am trying to install the RNetCDF package on my laptop (Ubuntu 12.04) with the command

install.packages('RNetCDF',lib='/home/my_computer/RSCRIPTS/R_LIB/',configure.args="--with-netcdf-include='/home/my_computer/bin/libs4cdo-0.0.10/netcdf-4.2/include/' --with-netcdf-lib='/home/my_computer/local/bin' --with-hdf5-lib='/home/my_computer/local/lib/' --with-udunits-include='/usr/local/lib/' --with-udunits-lib='/usr/local/lib/'",repos='http://star-www.st-andrews.ac.uk/cran/')

but the package won't install. See the message below:

trying URL 'http://star-www.st-andrews.ac.uk/cran/src/contrib/RNetCDF_1.6.1-2.tar.gz'
Content type 'application/x-gzip' length 70301 bytes (68 Kb)
opened URL
==================================================
downloaded 68 Kb

* installing *source* package ‘RNetCDF’ ...
** package ‘RNetCDF’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking for nc_open in -lnetcdf... yes
checking for utInit in -ludunits2... no
checking for utScan in -ludunits2... yes
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking netcdf.h usability... yes
checking netcdf.h presence... yes
checking for netcdf.h... yes
checking udunits.h usability... yes
checking udunits.h presence... yes
checking for udunits.h... yes
configure: creating ./config.status
config.status: creating R/load.R
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/share/R/include -I/usr/local/lib/ -I/home/bauduinm/bin/libs4cdo-0.0.10/netcdf-4.2/include/      -fpic  -O3 -pipe  -g -c RNetCDF.c -o RNetCDF.o
gcc -std=gnu99 -shared -o RNetCDF.so RNetCDF.o -ludunits2 -lnetcdf -L/home/my_computer/local/lib/ -L/usr/local/lib/ -L/home/my_computer/local/bin -lexpat -L/usr/lib/R/lib -lR
installing to /home/my_computer/RSCRIPTS/R_LIB/RNetCDF/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
 unable to load shared object '/home/my_computer/RSCRIPTS/R_LIB/RNetCDF  /libs/RNetCDF.so':
libexpat.so.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed  
* removing ‘/home/my_computer/RSCRIPTS/R_LIB/RNetCDF’

The downloaded packages are in
‘/tmp/Rtmpl5MniY/downloaded_packages’
Warning message:
In install.packages("RNetCDF", lib = "/home/my_computer/RSCRIPTS/R_LIB/",  :
    installation of package ‘RNetCDF’ had non-zero exit status

When I try with

sudo R CMD INSTALL --libary='/home/my_computer/RSCRIPTS/R_LIB/' --configure-args="--with-netcdf-include='/home/my_computer/bin/libs4cdo-0.0.10/netcdf-4.2/include/' --with-netcdf-lib='/home/my_computer/local/lib/' --with-hdf5-lib='/home/my_computer/local/lib/' --with-udunits-include=/usr/local/lib/ --with-udunits-lib=/usr/local/lib/" /home/my_computer/Downloads/RNetCDF_1.6.1-2.tar.gz

the error message is replaced with

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
unable to load shared object '/usr/local/lib/R/site-library/RNetCDF/libs/RNetCDF.so':
  libnetcdf.so.7: cannot open shared object file: No such file or directory

libnetcdf.so.7 is definitely in /home/my_computer/local/lib/ which is also my LD_LIBRARY_PATH. Admittedly, the libexpat.so.0, which is one of the files in the first error message (with install.packages), is situated in intel related folders which don't look like they have anything to do with netcdf libraries.

Could anyone enlighten me?

Thanks.

Edit: Well, I'll never know what happened because when I tried again 3 days later with the exact same install.packages command line the package installed without any problems whatsoever... So my only advice to someone who may have the same problem is to log out of R and start again, just in case some previous mistakes in the session remained in the log.

解决方案

Try adding --no-test-load to R CMD INSTALL this will avoid the error during the install.

Then check if you can load the package in a normal R session (with library(RNetCDF)). If this fails due to the 'unable to load shared object' error:

  1. check if R uses your $LD_LIBRARY_PATH with Sys.getenv("LD_LIBRARY_PATH")
  2. look the output of ldd /usr/local/lib/R/site-library/RNetCDF/libs/RNetCDF.so and see whether the libnetcdf.so.7 is resolved to path that is included in R's LD_LIBRARY_PATH

BTW, I had no problems installing RNetCDF using the libnetcdf that comes with Ubuntu (apt-get install libnetcdf-dev [version 4.1.1]); unless you definitely need version 4.2 of libnetcdf you might want to try this.

这篇关于RNetCDF无法打开共享库文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆