Originally posted by: JorisK
Ok, after several hours I managed to find the solution how to get rid of the famous "Native code library failed to load: ensure the appropriate library (oplXXX.dll/.so) is in your path." error under linux/java/eclipse. This is how you resolve it.
1. Obviously, first install Cplex_StudioXXX
2. Copy the oplall.jar and ILOG.CP.jar files which you find somewhere in the install dir to your eclipse project, and add them to your build path. Make sure they are visible under "Referenced Libraries". Make sure you do not add cplex.jar to your buildpath as well, because then the error will change from opl124.dll to opl10.dll which
3. Next, go to Window->preferences->Installed JRE->select your JRE and click edit. Under Default VM Argument, set: -Djava.library.path=/opt/ILOG/CPLEX_Studio124/opl/bin/x86-64_sles10_4.1/:/opt/ILOG/CPLEX_Studio124/cplex/bin/x86-64_sles10_4.1/:/opt/ILOG/CPLEX_Studio124/opl/oplide/:/opt/ILOG/CPLEX_Studio124/cpoptimizer/bin/x86-64_sles10_4.1/ obviously adjusted to your own system configuration.
4. Go to Run->Run Configurations->select the tab Environment (it might be hidden behind the ">>"). Under Environment variables, click new. Make a new variable as follows (again, adjusted to your own configuration):
Name: LD_LIBRARY_PATH
Value: /opt/ILOG/CPLEX_Studio124/cpoptimizer/bin/x86-64_sles10_4.1/:/opt/ILOG/CPLEX_Studio124/cplex/bin/x86-64_sles10_4.1/:$LD_LIBRARY_PATH
hit ok and click run.
This resolved my problem. In /opt/ILOG/CPLEX_Studio124/cpoptimizer/examples/x86-64_sles10_4.1/static_pic/ I found a makefile which explains how to run the java class from the command line. Below I've pasted some relevant parts:
CONCERTDIR = ../../../../concert CPLEXDIR = ../../../../cplex JAVA = $(JAVA_HOME)/bin/java JAVAC = $(JAVA_HOME)/bin/javac JAVAFLAGS = -d64 CPCLASSPATH = ../../../lib/ILOG.CP.jar LIBRARYPATH = ../../../bin/x86-64_sles10_4.1:$(CPLEXDIR)/bin/x86-64_sles10_4.1 JAVAEXDIR = ../../../examples/src/java all: java java: Sports.class execute: execute_java clean: rm -f sports *.
class FORCE: $(JAVAC): @echo
"####################################" @echo
"Error: cannot find the javac command" @echo
"Please ensure that JAVA_HOME is set correctly" @echo
"Currently, JAVA_HOME = $(JAVA_HOME)" @exit 1 Sports.class: $(JAVAC) $(JAVAC) -d . -classpath $(CPCLASSPATH) $(JAVAEXDIR)/Sports.java Sports.run: Sports.class FORCE LD_LIBRARY_PATH=$(LIBRARYPATH):$$LD_LIBRARY_PATH $(JAVA) $(JAVAFLAGS) -classpath $(CPCLASSPATH):. Sports execute_java: Sports.run
Here Sports.class is an example class which is shipped with the ILOG CPLEX studio. Note, the above code originates from a much larger make file. The original makefile also contains the compilation/run instructions for the other example classes, as well as for the C++ examples!
It is pretty pity that such an advanced, nice software package as ILOG Cplex Studio is that difficult to install under linux. Given IBM's resources, it can't be that hard to write a proper installation manual right?
#CPOptimizer#DecisionOptimization