shared library issue with the system function in R

谁说胖子不能爱 提交于 2019-12-11 05:49:32

问题


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

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:/# 

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 ?

Regards


回答1:


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> 

Edit: 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> 


来源:https://stackoverflow.com/questions/42044342/shared-library-issue-with-the-system-function-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!