javajava-native-interfaceor-toolsscip

Making SCIP for JNI and Or-Tools


Trying SCIP for the first time. Couldn't quite wrap my head around how to use JNI with SCIP version 8.x.x. on MacOs.

I downloaded scipoptsuite-8.0.4 from the website, then followed instruction of how to compile it:

mkdir build
cd build
cmake ..  -DAUTOBUILD=on
make
make install

After that I verified, that shared library is created:

➜ ls /usr/local/lib/libscip.dylib
/usr/local/lib/libscip.dylib

Then I followed the instructions from Or-Tools and did this:

            System.loadLibrary("scip"); // added to verify, that shared lib is accessible
            MPSolver mpSolver = MPSolver.createSolver("SCIP");

And I got this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'long com.google.ortools.linearsolver.mainJNI.MPSolver_createSolver(java.lang.String)'
    at com.google.ortools.linearsolver.mainJNI.MPSolver_createSolver(Native Method)
    at com.google.ortools.linearsolver.MPSolver.createSolver(MPSolver.java:140)
    at org.example.Solver.solve(Solver.java:58)
    at org.example.Solver.main(Solver.java:24)

Sadly, I do not have any C++ related background to proceed any further than that.


Solution

  • It's so happend, that after two hours of digging, I found out, that I completly forgot to include:

    Loader.loadNativeLibraries();

    before actually loading this lib by Or-Tools.

    Hopefully, someone in the future will spend less time investigating something like this.