I have a control problem which i solved by using Model predictive control (MPC). I have stated the problem in MATLAB and used FORCES http://forces.ethz.ch/ to solve it. FORCES is a web service from ETH Zürich which generates library-free ANSI-C code. For testing the code they provide a script to compile the c-code to a MATLAB .mex file. This all works great.
I now want to use this function in my C# Windows Forms programm. To use C-code in C# I have to compile the c-code to a dll and then use P/Invoke? Or is there an other way? How can I compile it? Can I just use the code as it is or do I have to edit it (adding __declspec or something like that)? Is it possible to compile the dll directly out of MATLAB?
The .c and .h files can be found on my homepage: http://n.ethz.ch/~rehofman/download/.
I run 64bit Windows 7, MATLAB 2013b, Visual Studio 2012.
I have MinGW already installed if that is needed.
EDIT:
Ok here is a more specific question: I have a function(myMPC_solve) written in c-code which I want to call from c#. What is the best way to do so? The arguments and datatypes are all in the .h file.