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

Wil*_*ane 2 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*
Run Code Online (Sandbox Code Playgroud)

我正在使用安装了 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
Run Code Online (Sandbox Code Playgroud)

Dir*_*tel 9

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

libudunits2.so.0: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)

并且您可以通过执行 RHEL 等效项来解决此问题

sudo apt-get install libudunits2-dev
Run Code Online (Sandbox Code Playgroud)

获取构建所需的头文件和可链接库,除了libudunits2您可能已经拥有的仅允许您运行共享对象代码,但不能链接到它。

抱歉,apt-get我没有快速的方法来搜索yum你的例子。 原则保持不变:您需要匹配的-dev包。