Running or-tools in IntelliJ (UnsatisfiedLinkError)

1,346 views
Skip to first unread message

Rick Bhardwaj

unread,
Jun 6, 2017, 6:03:19 PM6/6/17
to or-tools-discuss
Has anybody managed to run or-tools in IntelliJ? I'm able to compile, build, and run the package plus one of the examples; i.e., this works:
ip-192-168-1-67:or-tools rick$ java -Djava.library.path=/Users/rick/github/or-tools/lib -cp objs:/Users/rick/github/or-tools/lib/com.google.ortools.jar:/Users/rick/github/or-tools/lib/protobuf.jar com.google.ortools.samples.SimpleRoutingTest

cost
= 13


However, I cannot run the package in IntelliJ. I've added the ortools jar to my module dependencies as well as added -Djava.libarry.path=blahblahblah to my VM options in my run configuration. This is the code:

RoutingModel routingModel = new RoutingModel(tour.getStops().size(),
NUMBER_OF_ROUTES, NUMBER_OF_DEPOTS);
routingModel.setArcCostEvaluatorOfAllVehicles(new ArcCostEvaluator(tour));
RoutingSearchParameters searchParameters = RoutingSearchParameters.newBuilder()
.mergeFrom(RoutingModel.defaultSearchParameters())
.setFirstSolutionStrategy(FirstSolutionStrategy.Value.PATH_CHEAPEST_ARC)
.build();
Assignment solution = routingModel.solveWithParameters(searchParameters);

and this is the exception:

java.lang.UnsatisfiedLinkError: com.google.ortools.constraintsolver.operations_research_constraint_solverJNI.swig_module_init()V at com.google.ortools.constraintsolver.operations_research_constraint_solverJNI.swig_module_init(Native Method) at com.google.ortools.constraintsolver.operations_research_constraint_solverJNI.<clinit>(operations_research_constraint_solverJNI.java:2330) at com.google.ortools.constraintsolver.RoutingModel.<clinit>(RoutingModel.java:652) ... Process finished with exit code 255



Any clue?

Rick Bhardwaj

unread,
Jun 6, 2017, 7:07:23 PM6/6/17
to or-tools-discuss
Work around is to statically load jniortools, i.e.,

static { System.loadLibrary("jniortools");}

Not sure why pointing to the native library with the IntelliJ import tool is failing, will continue to debug that.
Reply all
Reply to author
Forward
0 new messages