I've run the Alloc example without the path to libopl and java is not able to find libcplex12100.jnilib: the rpath is not resolved.
However, if I replace the rpath by the absolute path, it works like a charm ! I don't know why java is not able to resolve the rpath even if the java.library.path contains the right folder (/Applications/CPLEX_Studio1210/cplex/bin/x86-64_osx).
Original Message:
Sent: Thu July 16, 2020 10:10 AM
From: Philippe Laborie
Subject: Cpoptimizer java and OSX
The only two libraries that are required are:
../../../bin/x86-64_osx/libcp_wrap_cpp_java12100.jnilib../../../../cplex/bin/x86-64_osx/libcplex12100.jnilib
It is not clear to me why they are not found when setting variable DYLD_LIBRARY_PATH.
When I'm using :
java -Djava.library.path=../../../bin/x86-64_osx:../../../../cplex/bin/x86-64_osx -classpath ../../../lib/ILOG.CP.jar:. Alloc
I get the same error as yours, it seems related with the fact the loader cannot find the CPLEX dynamic library (libcplex12100.jnilib) that is referenced in libcp_wrap_cpp_java12100.jnilib as @rpath/libcplex12100.jnilib (so I suppose here there is a problem in the specification of @rpath). I tried manually changing the path to library libcplex12100.jnilib in the CP Optimizer dynamic library libcp_wrap_cpp_java12100.jnilib by setting it to its absolute path by doing:
install_name_tool -change @rpath/libcplex12100.jnilib /Applications/CPLEX_Studio_1210/cplex/bin/x86-64_osx/libcplex12100.jnilib /Applications/CPLEX_Studio_1210/cpoptimizer/bin/x86-64_osx/libcp_wrap_cpp_java12100.jnilib
(My COS is installed in /Applications/CPLEX_Studio_1210). And then -Djava.library.path seems to work (and it is even not required to add the path to the cplex lib):
java -Djava.library.path=../../../bin/x86-64_osx -classpath ../../../lib/ILOG.CP.jar:. Alloc ! -------------------------------------------------- CP Optimizer 12.10.0.0 -- ! Minimization problem - 148 variables, 7746 constraints ! Presolve : 4131 extractables eliminated, 3918 constraints generated ! FailLimit = 40000 ! CountDifferentInferenceLevel = Extended ! LogPeriod = 100000 ! Initial process time : 0.06s (0.06s extraction + 0.00s propagation) ! . Log search space : 1184.0 (before), 1184.0 (after) ! . Memory usage : 3.4 MB (before), 3.4 MB (after) ! Using parallel search with 8 workers. ! ---------------------------------------------------------------------------- ! Best Branches Non-fixed W Branch decision 0 148 - + New bound is 0...
Maybe you could try something like this ...
------------------------------
Philippe Laborie
Original Message:
Sent: Wed July 15, 2020 06:09 PM
From: Antoine Legrain
Subject: Cpoptimizer java and OSX
Here the listing of the folders:
ls ../../../bin/x86-64_osx/cpoptimizer libcp_wrap_cpp_java12100.jnilibls ../../../../cplex/bin/x86-64_osx/cplex libcplex12100mpitransport.dylib libcplex12100remotejni.jnilibcplexamp libcplex12100mpiworker.dylib libcplex12100tcpiptransport.dylibcpxworker libcplex12100processtransport.dylib libcplex12100tcpipworker.dyliblibcplex12100.dylib libcplex12100processworker.dyliblibcplex12100.jnilib libcplex12100remote.dylibls ../../../../opl/bin/x86-64_osx/libcplex12100.dylib libicudata.55.dylib libicutu.55.dyliblibcplex12100.jnilib libicudata.dylib libicutu.dyliblibcplex12100mpitransport.dylib libicui18n.55.dylib libicuuc.55.dyliblibcplex12100mpiworker.dylib libicui18n.dylib libicuuc.dyliblibcplex12100processtransport.dylib libicuio.55.dylib libopl12100.dyliblibcplex12100processworker.dylib libicuio.dylib liboplb.dyliblibcplex12100remote.dylib libicule.55.dylib liboplnl1.12.dyliblibcplex12100remotejni.jnilib libicule.dylib liboplnl1.dyliblibcplex12100tcpiptransport.dylib libiculx.55.dylib oplrunlibcplex12100tcpipworker.dylib libiculx.dylib oplrunjava
If I'm exporting DYLD_LIBRARY_PATH and running the Alloc example, I still have the same error (libopl not found).
However, if I set java.library.path, the opl library is found, but I still have the swig error. I've tried to add all the three folders to the PATH, but I still have the swig error.
/usr/bin/java -Djava.library.path=../../../bin/x86-64_osx:../../../../cplex/bin/x86-64_osx:../../../../opl/bin/x86-64_osx -classpath ../../../lib/ILOG.CP.jar:. AllocException in thread "main" java.lang.UnsatisfiedLinkError: ilog.concert.cppimpl.concert_wrapJNI.swig_module_init()V at ilog.concert.cppimpl.concert_wrapJNI.swig_module_init(Native Method) at ilog.concert.cppimpl.concert_wrapJNI.<clinit>(concert_wrapJNI.java:1621) at ilog.concert.cppimpl.IloEnv.<init>(IloEnv.java:49) at ilog.concert.IloModelerImpl.<init>(IloModelerImpl.java:34) at ilog.cp.IloCP.<init>(IloCP.java:128) at ilog.cp.IloCP.<init>(IloCP.java:121) at Alloc.main(Alloc.java:89)
------------------------------
Antoine Legrain
Original Message:
Sent: Wed July 15, 2020 06:22 AM
From: Philippe Laborie
Subject: Cpoptimizer java and OSX
I tried on my Mac also running under Catalina (10.15.4) and did not notice any problem:
[static_pic] ☞ make execute_java DYLD_LIBRARY_PATH=../../../bin/x86-64_osx:../../../../cplex/bin/x86-64_osx /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/bin/java -classpath ../../../lib/ILOG.CP.jar:. Alloc ! -------------------------------------------------- CP Optimizer 12.10.0.0 -- ! Minimization problem - 148 variables, 7746 constraints ! Presolve : 4131 extractables eliminated, 3918 constraints generated ! FailLimit = 40000 ! CountDifferentInferenceLevel = Extended ! LogPeriod = 100000 ! Initial process time : 0.06s (0.06s extraction + 0.00s propagation) ! . Log search space : 1184.0 (before), 1184.0 (after) ! . Memory usage : 3.4 MB (before), 3.4 MB (after) ! Using parallel search with 8 workers. ! ---------------------------------------------------------------------------- ! Best Branches Non-fixed W Branch decision 0 148 - + New bound is 0 0 148 - + New bound is 1 * 116 948 0.24s 1 (gap is 99.14%) * 106 167 0.24s 3 (gap is 99.06%) ...
Could you send the list of files you have in ../../../bin/x86-64_osx and ../../../../cplex/bin/x86-64_osx ?
In fact I get the same errors like yours if I do not specify any path to the dynamic libraries (omitting DYLD_LIBRARY_PATH= in the command)
I know that recent versions of MacOS are very touchy about setting the environment variable on the command line. Could you try setting it with 'export' before running the execution :
export DYLD_LIBRARY_PATH=../../../bin/x86-64_osx:../../../../cplex/bin/x86-64_osx/usr/bin/java -classpath ../../../lib/ILOG.CP.jar:. Alloc
------------------------------
Philippe Laborie
Original Message:
Sent: Fri July 10, 2020 03:20 PM
From: Antoine Legrain
Subject: Cpoptimizer java and OSX
I don't remember installing older version. I have checked my PATH and I didn't find any cplex in it.
------------------------------
Antoine Legrain
Original Message:
Sent: Fri July 10, 2020 05:16 AM
From: Philippe Refalo
Subject: Cpoptimizer java and OSX
This problem can appear if you have in your path references to other (older) libraries of CPLEX/CP Optimizer. Then there is a mismatch between versions of the dynamic libraries found. Could you check that your path contains only references to the CPLEX version that you are currently using ?
Thanks.
Philippe
------------------------------
--
Philippe Refalo
IBM ILOG CP Optimizer
Original Message:
Sent: Mon July 06, 2020 12:29 PM
From: Antoine Legrain
Subject: Cpoptimizer java and OSX
I ran the examples of cpoptimizer, so "../../../bin/x86-64_osx" is "../../../../cpoptimizer/bin/x86-64_osx".
Thanks
------------------------------
Antoine Legrain
Original Message:
Sent: Mon July 06, 2020 12:10 PM
From: Paul Rubin
Subject: Cpoptimizer java and OSX
Does it help if you also add ../../../../cpoptimizer/bin/x86-64_osx to the library path?
------------------------------
Paul Rubin
Professor Emeritus
Michigan State University
Original Message:
Sent: Sat July 04, 2020 03:41 PM
From: Antoine Legrain
Subject: Cpoptimizer java and OSX
Hi,
I'm trying to run a java program with cpoptimizer and I have some linkage errors. So, I've tried to do the same with the examples, and I still have the same errors. By the way, Cplex is working fine and I'm using cplex 12.10 on macOS Catalina (10.15.4).
So, if I use the Makefile in the examples and I run "make java", everything compiles correctly. However, if I run "make execute_java", I have the following error:
make execute_javaDYLD_LIBRARY_PATH=../../../bin/x86-64_osx:../../../../cplex/bin/x86-64_osx /usr/bin/java -classpath ../../../lib/ILOG.CP.jar:. AllocNative code library failed to load: ensure the appropriate library (libopl12100.dylib) is in your path.
If I had opl lib to the path, I still have the same error:
make execute_javaDYLD_LIBRARY_PATH=../../../bin/x86-64_osx:../../../../cplex/bin/x86-64_osx:../../../../opl/bin/x86-64_osx /usr/bin/java -classpath ../../../lib/ILOG.CP.jar:. AllocNative code library failed to load: ensure the appropriate library (libopl12100.dylib) is in your path.
In my code, I have the following swig error when I add ""libopl12100.dylib":
Exception in thread "main" java.lang.UnsatisfiedLinkError: ilog.concert.cppimpl.concert_wrapJNI.swig_module_init()V at ilog.concert.cppimpl.concert_wrapJNI.swig_module_init(Native Method) at ilog.concert.cppimpl.concert_wrapJNI.<clinit>(concert_wrapJNI.java:1621) at ilog.concert.cppimpl.IloEnv.<init>(IloEnv.java:49) at ilog.concert.IloModelerImpl.<init>(IloModelerImpl.java:34) at ilog.cp.IloCP.<init>(IloCP.java:128) at ilog.cp.IloCP.<init>(IloCP.java:121)
Any idea please ?
Thanks
------------------------------
Antoine
------------------------------
#DecisionOptimization