0

The Problem

Hello I have the following problem. I installed 7.0.2 my computer, ubuntu 14.04, with R 3.3.3 another canoe, with RStudio 1.0.143.

After installing gurobi and slam I tried loading it:

library(gurobi)
Loading required package: slam
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
unable to load shared object '/home/derek/R/x86_64-pc-linux-gnu-library/3.3/gurobi/libs/gurobi.so':
libgurobi70.so: cannot open shared object file: No such file or directory
Error: package or namespace load failed for ‘gurobi’

I found this solution, but do not know how to do this:

The quickstart of the program states the following:

If you are using R from RStudio Server and you get an error indicating that R is unable to load the Gurobi DLL or shared object, you may need to set the rsession-ld-library-path entry in the server config file. I am using just RStudio, not the server, I searched for rsession-ld-library-path in my computer, but can't find it, I found a lot of support for that in RStudio Server, but not for RStudio.

Another solution I actually tried but did not work

I tried pasting the libgurobi70.so in the ~/R/x86_64-pc-linux-gnu-library/3.3/gurobi/libs folder, and it did not work, so I also

Some other solutions

I looked at this solution but I haven't changed my Ubuntu, I also saw this post, but the solution is for mac, I have been looking for the DYLD_FALLBACK_LIBRARY_PATH. they mention, and cant seem to find it.

Nothing seemed to work. Any help would be appreciated

Community
  • 1
  • 1
Derek Corcoran
  • 3,930
  • 2
  • 25
  • 54
  • 2
    Gurobi appears to be commerical software so why don't you ask their help desk? In general, to make a _non-standard_ library visible from _non-standard_ location, you can use `/etc/ld.so.conf.d/`, add a file there and run `ldconfig`. – Dirk Eddelbuettel May 16 '17 at 17:10
  • The comment from Dirk is the only solution that worked for me under Ubuntu 18.04. I just added another conf file to the `/etc/ld.so.conf.d/` pointing to the gurobi library folder. – Curlew Apr 08 '19 at 13:43
  • Dirk's comment is also the only solution that worked for me under Linux Mint 20.1 (Ubuntu 20.04). – scabecks Jul 08 '21 at 08:40

2 Answers2

1

I had a very similar error and wanted to add my solution in the hope that it will be useful to someone. The problem seems to be that the library path has not been set. I did this by editing the .bashrc file, adding the following at the end the file:

# Added for Gurobi:
export GUROBI_HOME="/opt/gurobi751/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${GUROBI_HOME}/lib"

In the first part you will need to set /opt/gurobi751/linux64 to whatever your Gurobi home folder is.

As I am totally new to Linux, and this might be useful to fellow newbies, I'll also add that to edit the .bashrc file, I used the Terminal with the following command nano .bashrc. This gets you into the basic text editor where you can copy and paste the code into the .bashrc file. Once this is done, restart.

Note that I am using Gurobi 7.5.1 so cannot guarantee that this solution will solve the problem on a different version.

UPDATED 6 JULY 2018

I tried using Gurobi via R recently and it didn't work. I have had to do the following to get it working:

  1. Add library path for R: Edit etc/R/ldpaths - open as sudo and add the following:

    : ${R_LD_LIBRARY_PATH=${GUROBI_HOME}/lib}

  2. ALSO! Need to add a file in the directory etc/profile.d. Create file with the following text in it:

    export GUROBI_HOME="/opt/gurobi751/linux64" export PATH="${PATH}:${GUROBI_HOME}/bin" export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"

and save as "gurobi751.sh" in that directory.

It seems like you only need to do parts 1 and 2 to get Gurobi to run in R. However, if you don't edit the the .bashrc file, as suggested in my original answer, Gurobi won't run from the command line.

Jason
  • 112
  • 1
  • 6
0

As commented by Dirk, if we add a conf file in /etc/ld.so.conf.d which contains the path to gurobi library (/opt/gurobi901/linux64/lib) followed by runnning ldconfig command, gurobi will be loaded properly in R environment.
I tried the same on an Ubuntu 18.04 system.

m02ph3u5
  • 3,022
  • 7
  • 38
  • 51