Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed or-tools in a C# application?

Tags:

c#

or-tools

I'm trying to follow the instructions at https://developers.google.com/optimization/introduction/installing.html#windows_binary so that I can use or-tools inside my C# application.

I'm stuck on the make all step. I am in the Developer Command Prompt, but this command says:

'make' is not recognized as an internal or external command,
operable program or batch file.

I tried downloading GNU make, but that fails also. make install says "no target", and a bare make says:

process_begin: CreateProcess(NULL, cl /EHsc /MD /nologo /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -nologo /O2 -DNDEBUG -DUSE_CBC -DUSE_CLP /D__WIN32__ /Iinclude\src\windows /DGFLAGS_DLL_DECL= /DGFLAGS_DLL_DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= /Iinclude /Iexamples -DUSE_GLOP -DUSE_BOP -c examples\cpp\costas_array.cc /Foobjs\costas_array.obj, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [objs\\costas_array.obj] Error 2

I also tried copying the DLLs from the bin folder directly into my project. I was able to compile against them by doing this, but when I tried to run it I got an error:

System.BadImageFormatException: 'Could not load file or assembly 'Google.OrTools, Version=5.1.6235.37215, Culture=neutral, PublicKeyToken=7a052e3db761d3be' or one of its dependencies. An attempt was made to load a program with an incorrect format.'

What am I missing?

like image 761
Xavier Shay Avatar asked Sep 18 '25 21:09

Xavier Shay


1 Answers

Regarding the System.BadImageFormatException:

The OrTools binary format is provided in a 64bit dll.

Make sure, that your project is set to 64bit:

In Visual Studio you can check it out by right clicking on the Project --> Properties --> Build, Platform Target: This should be set to x64.

like image 98
BotondF Avatar answered Sep 20 '25 12:09

BotondF