R中系统功能的共享库问题 [英] shared library issue with the system function in R

查看:234
本文介绍了R中系统功能的共享库问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ubuntu 16.04上工作(在docker容器内部).

I work on ubuntu 16.04 (inside a docker container).

libroffice已安装并且可以正常工作.

libroffice is installed and work fine.

我可以在命令行中使用它:

I can use it with command line:

root@07ff3fbcb3cd:/# libreoffice --version
LibreOffice 5.2.4.2.1 20m0(Build:2)
root@07ff3fbcb3cd:/# libreoffice --headless --convert-to pdf --outdir . rapport.docx                                                            
convert /rapport.docx -> /rapport.pdf using filter : writer_pdf_Export
root@07ff3fbcb3cd:/# 

但是,如果我尝试在R中做同样的事情:

But if I try to do the same in R:

R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> system("whoami")
root
> system(paste0("libreoffice --version")) 
/usr/lib/libreoffice/program/soffice.bin: error while loading shared libraries: libreglo.so: cannot open shared object file: No such file or directory
> system(paste0("libreoffice --headless --convert-to pdf --outdir . rapport.docx"))
/usr/lib/libreoffice/program/javaldx: error while loading shared libraries: libreglo.so: cannot open shared object file: No such file or directory
Warning: failed to read path from javaldx
/usr/lib/libreoffice/program/soffice.bin: error while loading shared libraries: libreglo.so: cannot open shared object file: No such file or directory

我不了解此共享库错误... 有什么主意吗?

I dont understand this shared library error... Any idea ?

致谢

推荐答案

只需永久设置库路径,只需在目录/etc/ld.so.conf.d/中添加以.conf结尾的文件即可,或者仅通过环境变量:

Just set the library path, permanently by adding a file ending in .conf in the directory /etc/ld.so.conf.d/, or just for the one command via the LD_LIBRARY_PATH environment variable:

edd@max:~$ LD_LIBRARY_PATH=/usr/lib/libreoffice/program/ R

R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

R> system(paste0("libreoffice --version")) 
LibreOffice 5.2.2.2 20m0(Build:2)

R> 

实际上,也许其他问题在您的末端是错误的,因为在这里它也可以与env.var一起使用:

Actually, maybe something else is wrong at your end because here it also works with the env.var:

edd@max:~$ R

R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

R> system(paste0("libreoffice --version"))
LibreOffice 5.2.2.2 20m0(Build:2)

R> 

这篇关于R中系统功能的共享库问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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