Error in CPLEX integration in .NET

423 views
Skip to first unread message

AM

unread,
Dec 6, 2019, 3:39:08 PM12/6/19
to or-tools...@googlegroups.com
Hi

When I add the following lines to include CPLEX, I can't even run CBC which is very strange:

>tools\make clean_third_party

>tools\make clean

> Change line 127 in Makefile.win.mk to:   STATIC_CPLEX_LNK = "$(WINDOWS_CPLEX_DIR)\\lib\x64_windows_vs2017\stat_mda\cplex1290.lib"

>tools\make third_party

> add WINDOWS_CPLEX_DIR=C:\Program Files\IBM\ILOG\CPLEX_Studio129\cplex to Makefile.local

>tools\make dotnet

>tools\make run SOURCE=examples/dotnet/csintegerprogramming.cs
"C:\Program Files\dotnet\dotnet.EXE" build examples\\dotnet\\csintegerprogramming.csproj
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 539.1 ms for C:\or-tools\examples\dotnet\csintegerprogramming.csproj.
  csintegerprogramming -> C:\or-tools\examples\dotnet\bin\x64\Debug\netcoreapp2.1\Google.OrTools.csintegerprogramming.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.45
"C:\Program Files\dotnet\dotnet.EXE" run --no-build  --project examples\\dotnet\\csintegerprogramming.csproj
---- Integer programming example with GLPK ----
Could not create solver GLPK_MIXED_INTEGER_PROGRAMMING
---- Linear programming example with CBC ----

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Google.OrTools.LinearSolver.operations_research_linear_solverPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'google-ortools-native' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Google.OrTools.LinearSolver.operations_research_linear_solverPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_operations_research_linear_solver(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
   at Google.OrTools.LinearSolver.operations_research_linear_solverPINVOKE.SWIGExceptionHelper..cctor()
   --- End of inner exception stack trace ---
   at Google.OrTools.LinearSolver.operations_research_linear_solverPINVOKE.SWIGExceptionHelper..ctor()
   at Google.OrTools.LinearSolver.operations_research_linear_solverPINVOKE..cctor()
   --- End of inner exception stack trace ---
   at Google.OrTools.LinearSolver.operations_research_linear_solverPINVOKE.new_Solver(String jarg1, Int32 jarg2)
   at Google.OrTools.LinearSolver.Solver..ctor(String name, OptimizationProblemType problem_type)
   at Google.OrTools.LinearSolver.Solver.CreateSolver(String name, String type)
   at CsIntegerProgramming.RunIntegerProgrammingExample(String solverType) in C:\or-tools\examples\dotnet\csintegerprogramming.cs:line 21
   at CsIntegerProgramming.Main() in C:\or-tools\examples\dotnet\csintegerprogramming.cs:line 111
tools\make: *** [run] Error -532462766

Any help is appreciated.

Thanks



Laurent Perron

unread,
Dec 6, 2019, 4:49:00 PM12/6/19
to or-tools-discuss
From the Makefile.local:

# Define UNIX_CPLEX_DIR to use CPLEX 
and WINDOWS_CPLEX_DIR on windows.
Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/6b230d14-8d31-4963-80e9-2dd8a937ecd1%40googlegroups.com.

AM

unread,
Dec 6, 2019, 4:52:42 PM12/6/19
to or-tools-discuss
I defined WINDOWS_CPLEX_DIR in Makefile.local in Windows OS. what else should I do?
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools...@googlegroups.com.

Laurent Perron

unread,
Dec 6, 2019, 5:14:13 PM12/6/19
to or-tools-discuss
Add the dll to your path


To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/97f65d6b-aafb-48c6-be55-727d84408ccb%40googlegroups.com.


--
--Laurent

AM

unread,
Dec 6, 2019, 5:38:47 PM12/6/19
to or-tools-discuss
Thanks.


On Friday, December 6, 2019 at 4:14:13 PM UTC-6, Laurent Perron wrote:
Add the dll to your path


Message has been deleted

AM

unread,
Dec 12, 2019, 4:11:38 AM12/12/19
to or-tools...@googlegroups.com
I checked,  all below directories are in my system path

C:\or-tools\ortools\dotnet\Google.OrTools\bin\x64\Release\net452
C:\or-tools\lib
C:\Program Files\IBM\ILOG\CPLEX_Studio129\cplex\bin\x64_win64

I still get the same error.

Manuel Ruiz

unread,
Dec 12, 2019, 4:20:02 AM12/12/19
to or-tools...@googlegroups.com
Hi Amir,
The error says that the native ortools dll is missing, could you check if it is in one of the repositories you listed ? 
May be you can also use Dependency Walker to check shared libraries dependencies.

Hope this helps

Manuel

Le jeu. 12 déc. 2019 à 10:11, AM <amir.m...@alumni.utoronto.ca> a écrit :
I checked all below directories are in my system path

--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/f56f9769-26e9-4864-aeed-1570f173ff66%40googlegroups.com.


--
  Manuel Ruiz

AM

unread,
Dec 12, 2019, 9:18:37 AM12/12/19
to or-tools-discuss
Thanks Manuel. Yes native ortools dll is there and I used dumpbin to find all dependencies and all DLLs were in place. It was working and suddenly I start getting that error.

Amir


On Thursday, December 12, 2019 at 3:20:02 AM UTC-6, Manuel Ruiz wrote:
Hi Amir,
The error says that the native ortools dll is missing, could you check if it is in one of the repositories you listed ? 
May be you can also use Dependency Walker to check shared libraries dependencies.

Hope this helps

Manuel

To unsubscribe from this group and stop receiving emails from it, send an email to or-tools...@googlegroups.com.


--
  Manuel Ruiz
Reply all
Reply to author
Forward
0 new messages