【问题标题】:shared library issue with the system function in RR中系统函数的共享库问题
【发布时间】:2017-02-04 19:01:06
【问题描述】:

我在 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

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

问候

【问题讨论】:

    标签: r docker libreoffice


    【解决方案1】:

    只需设置库路径,通过在目录/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> 
    

    【讨论】:

    • 谢谢!完美(编辑/etc/ls.so.conf.d/libc.conf后我用了一点sudo ldconfig
    • 是的,您必须在进行更改后运行ldconfigldconfig -p | grep libreglo 也是一个很好的检查。替我向罗曼问好。
    • 我会的 ;) 问候
    • 也可以在R里面设置路径:r Sys.setenv(LD_LIBRARY_PATH = "/usr/lib/libreoffice/program/")
    猜你喜欢
    • 1970-01-01
    • 2021-11-30
    • 1970-01-01
    • 1970-01-01
    • 2019-07-03
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 2012-01-14
    相关资源
    最近更新 更多