Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting LD_LIBRARY_PATH from inside R

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:

  1. exporting a modified LD_LIBRARY_PATH from the configure script located in the R package.
  2. Creating a soft link to the shared library within the same configure script.

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.

like image 654
kgui Avatar asked Jan 05 '17 20:01

kgui


People also ask

How do I set LD_LIBRARY_PATH?

In your terminal, type the following sudo ldconfig and press enter on your keyboard. Close all your open terminals that you were using then open a new terminal session and run echo $LD_LIBRARY_PATH If you see the path you added is echoed back, you did it right.

How do I change the library PATH in r?

To set environment variable R_LIBS_USER in Windows, go to the Control Panel (System Properties -> Advanced system properties -> Environment Variables -> User Variables) to a desired value (the path to your library folder), e.g.

What should be in LD_LIBRARY_PATH?

Set the LD_LIBRARY_PATH to include the directory or directories that contain your libraries.


1 Answers

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')

and then, loading via library should work.

like image 51
kgui Avatar answered Sep 27 '22 21:09

kgui