从R内部设置LD_LIBRARY_PATH [英] Setting LD_LIBRARY_PATH from inside R
问题描述
我已经安装了R软件包,但是为了通过library
加载它,需要将LD_LIBRARY_PATH设置为一个名为libhts.so.2
的库所在的路径.加载仅在进入R之前编辑LD_LIBRARY_PATH时有效,而之后则无效.
I have installed an R package but, in order to load it via library
, the LD_LIBRARY_PATH needs to be set to the path where one of the libraries, called libhts.so.2
is located. The loading only works when editing the LD_LIBRARY_PATH before going into R, not after.
我尝试了几种不同的方法来解决这个问题:
I have tried several different methods in solving this:
- 从R包中的
configure
脚本导出修改后的LD_LIBRARY_PATH. - 在相同的
configure
脚本中创建指向共享库的软链接.
- exporting a modified LD_LIBRARY_PATH from the
configure
script located in the R package. - Creating a soft link to the shared library within the same
configure
script.
两个都不起作用,在我看来,一旦启动R,就有一个变量存储LD_LIBRARY_PATH的结果.也许解决方案是编辑该变量.
Both have not worked and it seems to me that there is a variable that stores the results of the LD_LIBRARY_PATH once R is started. Maybe the solution is editing that variable.
推荐答案
在 Hans Lub 的帮助下,解决问题的方法是使用dyn.load()
函数并提供完整的路径库:
With help from Hans Lub, the way to solve the problem is by using the dyn.load()
function and supplying the full path to the library:
dyn.load('path_to_library')
,然后通过library
加载应该可以.
and then, loading via library
should work.
这篇关于从R内部设置LD_LIBRARY_PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!