Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Library linking error in .NET/Java with CPLEX Optimization Studio 12.4 x64

    Posted Mon May 07, 2012 12:40 PM

    Originally posted by: SystemAdmin


    Hi everybody, I'm trying to use the x64 CPLEX .NET/Java library to practice a bit with the APIs. I successfully imported the oplall.dll library in my projects, but I'm getting a dynamic library linking error.

    Here is the log while using the .NET library:
    
    System.TypeInitializationException was unhandled Message=The type initializer 
    
    for 
    'ILOG.OPL.OplFactory' threw an exception. Source=oplall TypeName=ILOG.OPL.OplFactory StackTrace: at ILOG.OPL.OplFactory..ctor() at deadlines.Program.Main(String[] args) in C:\...\Program.cs:line 20 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.TypeInitializationException Message=The type initializer 
    
    for 
    'ILOG.OPL.opl_lang_wrap' threw an exception. Source=oplall TypeName=ILOG.OPL.opl_lang_wrap StackTrace: at ILOG.OPL.opl_lang_wrap.touch() at ILOG.OPL.OplFactory..cctor() InnerException: System.TypeInitializationException Message=The type initializer 
    
    for 
    'SWIGIloExceptionHelper' threw an exception. Source=oplall TypeName=SWIGIloExceptionHelper StackTrace: at ILOG.OPL.opl_lang_wrap.SWIGIloExceptionHelper..ctor() at ILOG.OPL.opl_lang_wrap..cctor() InnerException: System.TypeInitializationException Message=The type initializer 
    
    for 
    'ILOG.OPL.opl_lang_wrapPINVOKE' threw an exception. Source=oplall TypeName=ILOG.OPL.opl_lang_wrapPINVOKE StackTrace: at ILOG.OPL.opl_lang_wrapPINVOKE.SWIGRegisterIloExceptionCallbacks_opl_lang_wrap(SWIGIloExceptionDelegate iloExceptionDelegate, SWIGIloExceptionDelegate iloOplExceptionDelegate) at ILOG.OPL.opl_lang_wrap.SWIGIloExceptionHelper..cctor() InnerException: System.TypeInitializationException Message=The type initializer 
    
    for 
    'SWIGExceptionHelper' threw an exception. Source=oplall TypeName=SWIGExceptionHelper StackTrace: at ILOG.OPL.opl_lang_wrapPINVOKE.SWIGExceptionHelper..ctor() at ILOG.OPL.opl_lang_wrapPINVOKE..cctor() InnerException: System.DllNotFoundException Message=Unable to load DLL 
    'opl124_dotnet': The specified module could not be found. (Exception from HRESULT: 0x8007007E) Source=oplall TypeName=
    "" StackTrace: at ILOG.OPL.opl_lang_wrapPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_opl_lang_wrap(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate) at ILOG.OPL.opl_lang_wrapPINVOKE.SWIGExceptionHelper..cctor() InnerException:
    

    And this is the (pretty much similar) runtime error which I get when using the Java library:
    
    Native code library failed to load: ensure the appropriate library (opl124.dll/.so) is in your path. Exceptions: C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic124\opl\bin\x64_win64\opl124.dll: Can
    't find dependent libraries no opl_lang_wrap_cpp in java.library.path no opl_core_wrap_cpp_java124 in java.library.path no opl_core_wrap_cpp in java.library.path no cp_wrap_cpp_java124 in java.library.path no cp_wrap_cpp in java.library.path no concert_wrap_cpp_java124 in java.library.path no concert_wrap_cpp in java.library.path   Exception in thread 
    "AWT-EventQueue-0" java.lang.ExceptionInInitializerError at ilog.concert.cppimpl.IloEnv.<init>(IloEnv.java:49) at ilog.opl.IloOplFactory.<init>(IloOplFactory.java:70) at test.MainFrame$1.run(MainFrame.java:34) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$000(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.lang.RuntimeException: Native code library failed to load: ensure the appropriate library (opl124.dll/.so) is in your path. Exceptions: C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic124\opl\bin\x64_win64\opl124.dll: Can
    't find dependent libraries no opl_lang_wrap_cpp in java.library.path no opl_core_wrap_cpp_java124 in java.library.path no opl_core_wrap_cpp in java.library.path no cp_wrap_cpp_java124 in java.library.path no cp_wrap_cpp in java.library.path no concert_wrap_cpp_java124 in java.library.path no concert_wrap_cpp in java.library.path   at ilog.concert.IloJNILoader.loadJNI(IloJNILoader.java:80) at ilog.concert.cppimpl.concert_wrapJNI.<clinit>(concert_wrapJNI.java:15) ... 17 more
    

    I'm using Windows 7 Ultimate x64. I tried a couple of suggestions which I read on the forum (many others had this same issue):

    I added to the PATH environment variable the path "C:\Program Files\IBM\ILOG\CPLEX_Studio_Academic124\opl\bin\x64_win64" where both opl124_dotnet.dll and opl124.dll are.
    I also tried in VS 2010 to change the build platform target to x64 (even if this had no impact on the Java version).

    Both of them had no effect. Any other ideas?

    Regards,
    Stefano
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Library linking error in .NET/Java with CPLEX Optimization Studio 12.4 x64

    Posted Wed June 20, 2012 09:05 AM

    Originally posted by: SystemAdmin


    Uninstalling and reinstalling CPLEX Optimization Studio x86 fixed this issue. Not sure if it could have worked for the x64 version as well.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Library linking error in .NET/Java with CPLEX Optimization Studio 12.4 x64

    Posted Tue June 26, 2012 09:51 AM

    Originally posted by: D30R_Ryan_Consylman


    I am also having this problem, but uninstalling and reinstalling did nothing. I am trying to implement OPL in Java, and am currently on the preview edition.
    My error is identical to the Java error listed above. I have tried all the common solutions such as adding -Djava (path). I am also running in eclipse. Any
    help would be greatly appreciated.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Library linking error in .NET/Java with CPLEX Optimization Studio 12.4 x64

    Posted Tue July 10, 2012 02:01 PM

    Originally posted by: James86


    I had a lot of trouble with this one. (I have been working in Eclipse Java under Windows 7 (32 bit), so I will answer this question using that syntax.)

    So you add oplall.jar into your build path and set something like -Djava.library.path="C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32" in your VM arguments (for Eclipse). When the program runs, it loads in opl124.dll. This dll has dependencies though, so Windows will then try to look for the other dlls that this dll is dependent on. I checked many times that my system's PATH variable was setup correctly, but the dependencies were still not found for some reason. The only way I was able to get around this was to explicitly load in each dependent library upon runtime:
    System.load("C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32/ilog.dll");
    System.load("C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32/icudt42.dll");
    System.load("C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32/icuuc42.dll");
    System.load("C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32/icuin42.dll");
    System.load("C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32/dbkernel.dll");
    System.load("C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32/dblnkdyn.dll");
    System.load("C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32/cplex124.dll");
    System.load("C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32/oplnl1.dll");
    System.load("C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32/opl124.dll");

    For .NET, I expect that you would need to do the same thing.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Library linking error in .NET/Java with CPLEX Optimization Studio 12.4 x64

    Posted Wed July 11, 2012 02:14 PM

    Originally posted by: SystemAdmin


    You shouldn't need to explicitly load each dependent library. I believe the issue you faced is from setting -Djava.library.path="C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32". As you noted, this will not allow dependent libraries for OPL DLL to be loaded however, when you set "java.library.path" then adding "C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32" in system PATH is not going to help. Only when "java.library.path" is not explicitly set will the JVM initialize it with directories specified in system PATH.

    So, if you have "C:/Program Files/IBM/ILOG/CPLEX_Studio_Preview124/opl/bin/x86_win32" in system PATH and don't explicitly set -Djava.library.path then it should work fine.

    Regards,
    Faisal
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Library linking error in .NET/Java with CPLEX Optimization Studio 12.4 x64

    Posted Sat July 28, 2012 11:47 PM

    Originally posted by: James86


    I suppose that is true. I have a colleague who had success adding a local "path" variable to the Eclipse environment. That would suggest that what you say is true. I have not had the time to mess around with this further. I was just following the instructions found here:
    http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r2/index.jsp?topic=%2Filog.odms.cplex.help%2FContent%2FOptimization%2FDocumentation%2FCPLEX%2F_pubskel%2FCPLEX19.html
    #DecisionOptimization
    #OPLusingCPLEXOptimizer