簡體   English   中英

R中系統函數的共享庫問題

[英]shared library issue with the system function in R

我在 ubuntu 16.04(在 docker 容器內)工作。

libroffice 已安裝並且工作正常。

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

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 中做同樣的事情:

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

我不明白這個共享庫錯誤......知道嗎?

問候

只需通過在目錄/etc/ld.so.conf.d/添加一個以.conf結尾的文件來永久設置庫路徑,或者僅通過LD_LIBRARY_PATH環境變量為一個命令設置:

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:

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> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM