Gurobi works in RStudio but not R (can't find libgurobi65.so)

682 views
Skip to first unread message

Matt Strimas-Mackey

unread,
Mar 31, 2016, 3:25:45 AM3/31/16
to Gurobi Optimization
Setup: Mac OS X 10.11, Gurobi 6.5.1, R 3.2.4, RStudio 0.99.893

I'm able to load the gurobi R package without issue in RStudio, but when I do the same in plain R (i.e. via the Terminal) I get the following error:

Error in dyn.load(file, DLLpath = DLLpath, ...) : 

  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/gurobi/libs/gurobi.so':

  dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/gurobi/libs/gurobi.so, 6): Library not loaded: libgurobi65.so

  Referenced from: /Library/Frameworks/R.framework/Versions/3.2/Resources/library/gurobi/libs/gurobi.so

  Reason: image not found

Error: package or namespace load failed for ‘gurobi’


The issue is that libgurobi65.so can't be found, which based on my research has something to do with the DYLD_LIBRARY_PATH environment variable. What's odd is that it works fine in RStudio, but errors when R is run outside of RStudio.


Anyone else encountered this issue? Thanks!

Matt Strimas-Mackey

unread,
Mar 31, 2016, 11:02:39 AM3/31/16
to Gurobi Optimization
After a lot of trial and error, I've found a solution to the issue. I found there's an environmental variable in R called DYLD_FALLBACK_LIBRARY_PATH. It contains different values in RStudio than straight R, but in both cases /Library/Frameworks/R.framework/Resources/lib is present. Copying the libgurobi65.so file to this directory solved the problem.

If anyone has a solution that doesn't involve copying the file, or can explain why this happened, I'd be curious to hear.
Reply all
Reply to author
Forward
0 new messages