与R中的系统函数共享库问题

时间:2017-02-04 19:01:07

标签: r docker libreoffice

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

已安装libroffice并正常工作。

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

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

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

#lang racket

(define str
  "Beebe a reeble to one niner big druppy bonker watz. ")

(with-output-to-file "/tmp/foo.txt"
  (λ ()
    (for ([i (in-range (/ 500000 10))])
      (displayln str))))    

我不明白这个共享库错误... 有什么想法吗?

此致

1 个答案:

答案 0 :(得分:1)

只需在目录.conf中添加以/etc/ld.so.conf.d/结尾的文件,或通过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>