.NET support

641 views
Skip to first unread message

Laurent Perron

unread,
Jan 2, 2012, 5:50:52 PM1/2/12
to or-tools...@googlegroups.com
Hello, 

Thanks to the invaluable help of Mark Farkas, we have .NET support in or-tools.
This has been tested with visual studio 10.

We have 4 new targets:
  make csharp
  make csharpexe
  make cleancsharp
  make test_csharp

There are examples in or-tools/csharp and a complete solution in or-tools/csharp/solutions/.

CP Library with arithmetic operators and writing custom decision builder is supported.
LP is supported, but I have not yet written the arithmetic layer as in the python libraries.
Knapsack and graph algorithms are supported.

Please tell me if anything goes wrong.

--Laurent

Mark Farkas

unread,
Jan 3, 2012, 3:45:26 AM1/3/12
to or-tools...@googlegroups.com
Hi!

I am glad I could help. If something goes wrong, please mail me and I try to figure it
out if possible.

Regards,
Mark

Wouter

unread,
Jan 4, 2012, 6:47:26 PM1/4/12
to or-tools...@googlegroups.com
Really nice :-)

However I have a question and I hope you forgive me for asking. But how do I build or-tools to a dll for .NET? I fetched the source and went into the folder and opened the makefile for C# in visual studio, however there are no options for building. Sorry I'm really unfamilier with C sharp and Visual Studios. 

Laurent Perron

unread,
Jan 5, 2012, 2:14:45 AM1/5/12
to or-tools...@googlegroups.com
Hi,
1) it works only on Windows.
2) You need to build dependencies (see getting started on
code.google.com/p/or-tools).
3) then you can type 'make csharp'. It will build 4 Google.OrTools.XXX.dll.

to build the examples, you can either type:
make csharpexamples
or
open the solution and build it.

I hope this helps.

--Laurent

From or-tools, you need to type tools

2012/1/5 Wouter <wouter...@gmail.com>:

--
--Laurent

Wouter

unread,
Jan 5, 2012, 8:44:37 PM1/5/12
to or-tools...@googlegroups.com
I tried but I failed. I'm really newb on building on windows. But anyway... what I did:


First, create the or-tools svn copy where you want to work.
Check! "c:\or-tools\"

Then install python from http://www.python.org/download/releases/2.7/ 
Check (really don't know why I need python, since I want the .NET dll and the source is in C++, but what the hell :-P says it needs to be done)

If you wish to use glpk, please download glpk from http://ftp.gnu.org/gnu/glpk/glpk-4.47.tar.gz and put the archive in or-tools/dependencies/archives.  
Nah

Then you can download all dependencies and build them using: make third_party
Hmmm where do I need to use this command? Standard commandprompt from windows does not recognize this, visual studio either. Then I read...
All build rules use make (gnu make), even on windows. A make.exe binary is provided in the tools sub-directory. 
Ahhh so I need GNU make and a .exe is provided in "c:\or-tools\tools". Okay well I tried to start the make.exe located in "\tools" but when I click it it opens and closes again. So can't do much with that. However then I tried calling the .exe by the windows commandprompt like: 
C:\or-tools\tools>make C:\or-tools\makefiles\Makefile.third_party.win
make: Nothing to be done for `C:\or-tools\makefiles\Makefile.third_party.win'.

Hmmmm nothing to be done... can't be correct Well then I couldn't find the Makefile.local since I guess it gets created when running the "make third_party" command. 

I hope you can help me further :-)

Laurent Perron

unread,
Jan 6, 2012, 3:13:50 AM1/6/12
to or-tools...@googlegroups.com
OK,

let's build a 32 bit version of the libraries.
open a visual studio command prompt:
start menu -> Microsoft Visual Studio 2010 -> Visual Studio Tools ->
Visual studio command prompt
in the terminal, type:
c:
cd \or-tools
tools\make.exe third_party
tools\make.exe csharp

then you can open the solution and build the examples.
You should not need to install python, java, google-apputils, not
update the Makefile.local.

--Laurent

PS: to build a 64 bit version of the libraries, in a clean svn client,
open Visual Studio x64 Win64 Command Prompt and follow the same
procedure.

2012/1/6 Wouter <wouter...@gmail.com>:

--
--Laurent

Laurent Perron

unread,
Jan 6, 2012, 4:50:51 AM1/6/12
to or-tools...@googlegroups.com
 I have uploaded the current 32 and 64 bit versions of the dotnet assemblies.
Just unzip them at the root of or-tools and should should be ready to go (hopefully).

Thanks

Laurent Perron | Operations Research Team Lead |  lpe...@google.com | (33) 1 42 68 53 00

Wouter

unread,
Jan 6, 2012, 3:10:05 PM1/6/12
to or-tools...@googlegroups.com
Thank you very much. 

I also tried to compile it by myself but it didn't worked yet for me. First I had some trouble because I didn't had tortoise command line component installed. After that I tried to compile it but I get the error:

Done Building Project "c:\or-tools\dependencies\sources\coin-cbc\Cbc\MSVisualSt
udio\v10\Cbc.sln" (Build target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)
Time Elapsed 00:00:02.28
copy dependencies\sources\coin-cbc\Cbc\MSVisualStudio\v10\Win32\Release\*.lib de
pendencies\install\lib\coin
Het systeem kan het opgegeven pad niet vinden. (translated: The system can't find the given path)
make.exe: *** [dependencies\install\bin\cbc.exe] Error 1

When I go to "dependencies\sources\coin-cbc\Cbc\MSVisualStudio\v10\" I see that the path "Win32" does not exist. Only "x64" exists but that is for 64 bit. I'm 32 bit :-)
 

Wouter

unread,
Jan 6, 2012, 3:22:46 PM1/6/12
to or-tools...@googlegroups.com
ps. your 32 bit DLL's, http://code.google.com/p/or-tools/downloads/list generates a "System.BadImageFormatException" error,  http://msdn.microsoft.com/en-us/library/k7137bfe(v=vs.80).aspx

Laurent Perron

unread,
Jan 6, 2012, 3:58:35 PM1/6/12
to or-tools...@googlegroups.com
this means you are in 64 bit windows and the Cpu Type is AnyCPU.
Can you try forcing it to Win32 in the IDE.

It bit me before.

--Laurent


Laurent Perron | Operations Research Team Lead |  lpe...@google.com | (33) 1 42 68 53 00




Wouter

unread,
Jan 11, 2012, 6:36:54 AM1/11/12
to or-tools...@googlegroups.com
Update...

Seemed to be that the problem was not with the DLL but with the program I used. I namely wanted to create a wrapper for another language :-)

But all is fixed now. Thanks for all the help!

Laurent Perron

unread,
Jan 19, 2012, 5:01:14 PM1/19/12
to or-tools-discuss
Hello,




I have just pushed an experimental support of .NET using mono.
I have tested it successfully on ubuntu 11.04 32 bit. It should work
on 64 bit. I may work with an older version of ubuntu, of with other
linux distributions.

After the update, run make test_csharp to launch all c# executables.

For the Mac OS X support, I need a 64 bit build of mono. You have to
build it by hand. I will try it later.

--Laurent

hakank

unread,
Jan 20, 2012, 12:54:47 AM1/20/12
to or-tools-discuss
I can report that it now (SVN revision 1098) works on my Ubuntu 11.10,
64-bit.

Great work, Laurent and Mark!

/Hakan

Mark Farkas

unread,
Jan 20, 2012, 3:20:26 AM1/20/12
to or-tools...@googlegroups.com
Nice work :) Btw. Laurent: did you also incorporate routing interfaces?
I think it is missing from the default build.

Laurent Perron

unread,
Jan 20, 2012, 4:05:24 AM1/20/12
to or-tools...@googlegroups.com
Yes, actually the Google.OrTools.ConstraintSolver.dll contains the
routing interface.

--Laurent

2012/1/20 Mark Farkas <farka...@gmail.com>:

--
--Laurent

Ben

unread,
Jul 5, 2012, 4:15:25 AM7/5/12
to or-tools...@googlegroups.com
Hi,

I have just downloaded the .NET win32 DLL and tried to run some examples with LINQPAD but get the following error: 
The type initializer for 'Google.OrTools.ConstraintSolver.operations_researchPINVOKE' threw an exception.
Unable to load DLL 'c:\Users\lperron\Documents\or-tools\bin\Google.OrTools.ConstraintSolver.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I then started one of the projects in the "\or-tools.Win32\examples\csharp\solution\" folder and set the target platform to x86, and get the same exception as in LINQPAD.

Any ideas to make this work?

Cheers,

Ben

Laurent Perron

unread,
Jul 5, 2012, 4:23:32 AM7/5/12
to or-tools...@googlegroups.com

Hi,

I think I need to rebuild the dlls.

Can you build from source?

Thanks

Ben Orca

unread,
Jul 5, 2012, 7:12:44 PM7/5/12
to or-tools...@googlegroups.com
Yes should be able to build from source.

Ben Orca

unread,
Jul 6, 2012, 1:10:52 AM7/6/12
to or-tools...@googlegroups.com
I have tried building with VS command prompt 32 and 64, both failed.

The 64 build failed because it could not find
"dependencies\sources\gflags\autogen.sh"

Laurent Perron

unread,
Jul 6, 2012, 2:32:38 AM7/6/12
to or-tools...@googlegroups.com

Oh, you are not detecting that you are under windows.


Can you try to use make in or-tool\tools


like cd <or-tools>

tools\make.exe third_party


Thanks

Ben Orca

unread,
Jul 6, 2012, 4:02:04 AM7/6/12
to or-tools...@googlegroups.com
That is what I did. Went to the or-tools directory and then typed in:
> tools\make.exe third_party
There are a lot of things being inflated and created but the error at
the end is still the same.

Tried again with a fresh svn and same problem.

Laurent Perron

unread,
Jul 6, 2012, 9:54:33 AM7/6/12
to or-tools...@googlegroups.com
For all,

that was solved by making sure svn.exe is accessible from the command line tool.
I have highlighted this part in the getting started.

Thanks

2012/7/6 Ben Orca <operationsr...@gmail.com>:
--
--Laurent

Ben Orca

unread,
Jul 6, 2012, 10:08:08 AM7/6/12
to or-tools...@googlegroups.com
All working fine in LinqPad now. Thanks for your help Laurent.
Reply all
Reply to author
Forward
0 new messages