forum.alglib.net
http://forum.alglib.net/

Setting up ALGLIB in C# solution
http://forum.alglib.net/viewtopic.php?f=2&t=3944
Page 1 of 1

Author:  JonathanJohansen [ Wed Feb 20, 2019 3:54 am ]
Post subject:  Setting up ALGLIB in C# solution

Dear forum members,

I'm a new C# developer who did applied maths at uni, and I would love to use ALGLIB in my C# project - but I can't get it to build. This is what I've done:

  1. Downloaded C# free version from http://www.alglib.net/translator/re/alglib-3.14.0.csharp.gpl.zip
  2. Copied \csharp\net-core\src files from zip into a C# project
  3. Call code as contained in http://www.alglib.net/translator/man/manual.csharp.html#example_minbleic_d_2
  4. It wasn't working for some reason with a Class Library, so change to a Shared Library
  5. I get two duplicate assembly errors from alglib_info.cs - one for AssemblyCompanyAttribute and one for AssemblyProductAttribute
  6. Thus I remove alglib_info.cs and it builds okay and runs the example code.

I have many questions about this:

  • Why was it so hard?
  • Is the C# installation process documented anywhere?
  • Is this the normal process people follow to use ALGLIB?
  • Do people just use the Nuget dll somehow?

Author:  Sergey.Bochkanov [ Thu Feb 21, 2019 1:05 pm ]
Post subject:  Re: Setting up ALGLIB in C# solution

Hi!

1) Can you elaborate on the specific errors reported at alglib_info.cs? It is very short .cs file, I simply do not know what can be wrong with it.

2) Generally, ALGLIB is expected to be simple to use. Either you compile .cs files (and they have to compile without additional changes) or you use precompiled assembly alglibnet2.dll.

So, I'd be glad to hear what got wrong in your case in order to fix all possible issues.

Author:  JonathanJohansen [ Wed Mar 06, 2019 11:06 pm ]
Post subject:  Re: Setting up ALGLIB in C# solution

To replicate this I created a Windows Console Project, C# .NET Framework 4.7.1 in Visual Studio Community 2017 Version 15.9.7.

I created a small example project based on the above steps (example_minbleic_d_2) into a fresh .NET Framework Console project. I ran into two issues:

  • The methods at the end of the post aren't defined!
  • After commenting out the lines below, I get the same AssemblyInfo.cs errors.

I now see what the problem is. If I make a new C# project and include all the AlgLib files (incl. alglib_info.cs) in a C# project, Visual Studio defines its own assembly info in Properties⇒AssemblyInfo.cs. That clashes with alglib_info.cs. I think this would be avoided if AlgLib distributed the C# with a VS project, or mentioned this in the documentation.

I've attached the project (without some autogenerated stuff that should regenerate if you open the solution in Visual Studio) in a 7zip (had to to get it below 1MB) in case you want to refer to it.

Code:
alglib.minbleicoptguardsmoothness(state);
alglib.minbleicoptguardgradient(state, 0.001);

...
Code:
alglib.optguardreport ogrep;
alglib.minbleicoptguardresults(state, out ogrep);
System.Console.WriteLine("{0}", ogrep.badgradsuspected); // EXPECTED: false
System.Console.WriteLine("{0}", ogrep.nonc0suspected); // EXPECTED: false
System.Console.WriteLine("{0}", ogrep.nonc1suspected); // EXPECTED: false


Attachments:
File comment: 7zip of project as given in examples, with #region defined around missing methods.
AlgLibGo.7z [792.56 KiB]
Downloaded 45 times

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/