Ramy Fouad
Ramy Fouad

Reputation: 1

Problem with Gurobi java API: libgurobi95.so: cannot open shared object file: No such file or directory

I am trying to use the Gurobi java API for the first time and I am trying to run the MIP1 example here: https://www.gurobi.com/documentation/9.1/examples/mip1_java.html

I am using IntelliJ IDEA on Linux Ubuntu machine. I imported gurobi module to IntelliJ and the program build was done without errors. But when I try to run it, I get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/ramy/gurobi950/linux64/lib/libGurobiJni95.so: libgurobi95.so: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1850)
at java.lang.Runtime.loadLibrary0(Runtime.java:871)
at java.lang.System.loadLibrary(System.java:1124)
at gurobi.GurobiJni.<clinit>(GurobiJni.java:304)
at gurobi.GRBEnv.<init>(GRBEnv.java:107)
at com.example.java.Main.main(Main.java:20)

Process finished with exit code 1

Upvotes: 0

Views: 1910

Answers (3)

DaGeggo
DaGeggo

Reputation: 1

I got the same error in the newest version (gurobi 1102) and for me, it was a problem with the flathub installation. I am using Fedora 38 and previously installed IntelliJ using the gnome software manager https://apps.gnome.org/Software/.

Uninstalling it and using the jetbrains toolbox to install IntelliJ https://www.jetbrains.com/help/idea/installation-guide.html#-fmxayx_107 fixed the issue.

Upvotes: 0

liml
liml

Reputation: 1

I have encountered the same problem, and the environment variables are all set correctly. My solution is:

sudo ln -s $GUROBI_HOME/lib/libgurobi91.so /usr/lib
sudo ln -s $GUROBI_HOME/lib/libGurobiJni91.so /usr/lib
sudo ldconfig

Then, example programs can be executed. I am using version 9.1. If there is still an error, you can try to replace $GUROBI_HOME with the real path.

Upvotes: 0

mattmilten
mattmilten

Reputation: 6706

You need to set the LD_LIBRARY_PATH to point to your Gurobi installation's lib path as explained in the installation instructions of Gurobi.

For Gurobi 9.5, on Linux, this is typically achieved with these commands:

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

Upvotes: 3

Related Questions