install.packages()找不到共享的.so对象文件

时间:2018-04-04 17:51:31

标签: r

有人能建议前进的道路吗?

在尝试安装udunit2(R包)时,我收到以下错误,表明它找不到共享对象文件。我缺少一个环境变量吗?

/srv/shiny-server/r-packages是我的自定义R软件包安装目录。

我按https://www.unidata.ucar.edu/software/udunits/udunits-current/doc/udunits/udunits2.html#Obtain

安装了udunits2

udunits2是一个命令行工具。

更新:libudunits2.so.0似乎存在于我的系统上:

$ la /usr/local/lib
total 568
drwxr-xr-x.  3 root root   4096 Apr  4 14:56 ./
drwxr-xr-x. 12 root root   4096 Dec  8  2016 ../
-rw-r--r--.  1 root root 199466 Apr  4 14:56 libudunits2.a
-rwxr-xr-x.  1 root root    889 Apr  4 14:56 libudunits2.la*
lrwxrwxrwx.  1 root root     20 Apr  4 10:04 libudunits2.so -> libudunits2.so.0.1.0*
lrwxrwxrwx.  1 root root     20 Apr  4 10:04 libudunits2.so.0 -> libudunits2.so.0.1.0*
-rwxr-xr-x.  1 root root 131080 Apr  4 10:04 libudunits2.so.0.1.0*

我正在使用安装了DevToolSet-7的Red Hat Enterprise 6.9系统(因此,g ++ 7.2.1)。

> install.packages("udunits2")
Installing package into ‘/srv/shiny-server/r-packages’
(as ‘lib’ is unspecified)
trying URL 'http://cran.us.r-project.org/src/contrib/udunits2_0.13.tar.gz'
Content type 'application/x-gzip' length 67182 bytes (65 KB)
==================================================
downloaded 65 KB

* installing *source* package ‘udunits2’ ...
** package ‘udunits2’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
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 XML_ParserCreate in -lexpat... 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 udunits2.h usability... yes
checking udunits2.h presence... yes
checking for udunits2.h... yes
checking for ut_read_xml in -ludunits2... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -I/include  -c udunits2_R.c -o udunits2_R.o
gcc -std=gnu99 -shared -L/lib -o udunits2.so udunits2_R.o -ludunits2 -lexpat -lexpat -ludunits2
installing to /srv/shiny-server/r-packages/udunits2/libs
** R
** inst
** 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 '/srv/shiny-server/r-packages/udunits2/libs/udunits2.so':
  libudunits2.so.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/srv/shiny-server/r-packages/udunits2’

The downloaded source packages are in
        ‘/tmp/RtmpRqD9L6/downloaded_packages’
Warning message:
In install.packages("udunits2") :
  installation of package ‘udunits2’ had non-zero exit status

2 个答案:

答案 0 :(得分:1)

您误读了错误消息。它实际上说

libudunits2.so.0: cannot open shared object file: No such file or directory

你可以通过做RHEL等效的

来解决这个问题
sudo apt-get install libudunits2-dev

获取 build 所需的标题和可链接库,除了您可能已经拥有的libudunits2之外,它只允许您运行共享对象代码,但不是与之相关联。

apt-get示例的道歉没有快速搜索yum的方法。 原则保持不变:您需要匹配的-dev包。

答案 1 :(得分:1)

尝试一下:

在R控制台中,运行:

Sys.setenv(UDUNITS2_LIBS="/path/to/udunits2/lib")
Sys.setenv(UDUNITS2_INCLUDE="/path/to/udunits2/include")

然后

install.packages("udunits2")