Visual C support in Matlab/Simulink

Hello,

I was already able to use acados on Matlab sucessfully in closed loop simulation with MinGw.
Next step is to run it on a speedgoad for a real application.
Therefore, the Problem is created in Simulink. It can be used to programm the speedgoad.

Unfortunatelly it only supports the Visual C/Visual C++ compiler and not MinGw.
I tried to build the minimal_example_ocp.m with Microsoft Visual C++ 2017 (C).

Therefore i used following commands:

Then started Matlab

  • mex -setup: MEX configured to use 'Microsoft Visual C++ 2017 (C)
  • mbuild -setup: MBUILD configured to use ‘Microsoft Visual C++ 2017 (C)’
  • run \acados\examples\acados_matlab_octave\acados_env_variables_windows.m
  • run acados\examples\acados_matlab_octave\getting_started\minimal_example_ocp.m

The first files succeeded to build, but then it crashed. Can anyone help me please?

compiling C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave....\interfaces\acados_matlab_octave\ocp_create.c
Building with ‘Microsoft Visual C++ 2017 (C)’.
MEX completed successfully.
compiling C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave....\interfaces\acados_matlab_octave\ocp_destroy.c
Building with ‘Microsoft Visual C++ 2017 (C)’.
MEX completed successfully.
compiling C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave....\interfaces\acados_matlab_octave\ocp_create_ext_fun.c
Building with ‘Microsoft Visual C++ 2017 (C)’.
MEX completed successfully.
compiling C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave....\interfaces\acados_matlab_octave\ocp_destroy_ext_fun.c
Building with ‘Microsoft Visual C++ 2017 (C)’.
MEX completed successfully.
compiling C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave....\interfaces\acados_matlab_octave\ocp_solve.c
Building with ‘Microsoft Visual C++ 2017 (C)’.
MEX completed successfully.
compiling C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave....\interfaces\acados_matlab_octave\ocp_precompute.c
Building with ‘Microsoft Visual C++ 2017 (C)’.
MEX completed successfully.
compiling C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave....\interfaces\acados_matlab_octave\ocp_set.c
Building with ‘Microsoft Visual C++ 2017 (C)’.
MEX completed successfully.
compiling C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave....\interfaces\acados_matlab_octave\ocp_get.c
Building with ‘Microsoft Visual C++ 2017 (C)’.
MEX completed successfully.
compiling C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave....\interfaces\acados_matlab_octave\ocp_eval_param_sens.c
Building with ‘Microsoft Visual C++ 2017 (C)’.
MEX completed successfully.
acados MEX interface compiled successfully
Building with ‘Microsoft Visual C++ 2017 (C)’.
Error using mbuild (line 166)
Unable to complete successfully.
Bibliothek “C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave\getting_started\libpendulum.lib” und Objekt
“C:\Users\Freddy\acados_VC\acados\examples\acados_matlab_octave\getting_started\libpendulum.exp” werden erstellt.
LINK : fatal error LNK1561: Einstiegspunkt muss definiert werden.

Error in ocp_generate_casadi_ext_fun (line 170)
mbuild(c_files_path{:}, ‘-output’, lib_name, ‘CFLAGS=“$CFLAGS”’, ‘LDTYPE=“-shared”’, [‘LDEXT=’, ldext]);

Error in acados_ocp (line 141)
ocp_generate_casadi_ext_fun(obj.model_struct, obj.opts_struct);

Error in minimal_example_ocp (line 105)
ocp = acados_ocp(ocp_model, ocp_opts);

Thank you a lot and best regards,
Freddy

Hi Freddy,

sorry, I do not really know what the issue is.
The problem seems to occur when compiling the CasADi generated model functions.
Also, the error being German makes it harder to google.
Did you make some progress with the issue meanwhile?

I guess you mean speedgoat though :grin:

Cheers,
Jonathan

Hi FreyJo,

thank you for the answer.
Yes I also think the problem is the CasADi module, as it was compiled using MinGW. Unfortunately I did not really make process until now. If I will find a solution I will write it here.

Cheers,
Freddy

Hey,
this issue affected me too and I want to report some of my observations.

  • I successfully used first examples of acados some weeks ago.
  • In the meanwhile I have installed Visual Studio and Visual C and C++ Compilers. When running the acados examples (Matalb mex configured to use MinGW) I encountered the same error as Freddy.
  • After uninstalling the Visual C and C++ Compilers the error was gone.

The point I don’t understand is the following: I reinstalled Visual C and C++ Compilers and did not change the mex settings. All files but ocp_eval_param_sens.c are compiled with MinGW. Only ocp_eval_param_sens.c is compiled with the Visual C++ compiler.

...
compiling D:\acados\examples\acados_matlab_octave\..\..\interfaces\acados_matlab_octave\ocp_eval_param_sens.c
Building with 'MinGW64 Compiler (C)'.
MEX completed successfully.
acados MEX interface compiled successfully
Building with 'Microsoft Visual C++ 2017 (C)'.
Error using mbuild (line 166)
Unable to complete successfully.
   Bibliothek "W:\KC\***\Matlab\Systemidentifikation\MHE\PT2\libocp_model.lib" und Objekt
   "W:\KC\***\Matlab\Systemidentifikation\MHE\PT2\libocp_model.exp" werden erstellt.
LINK : fatal error LNK1561: Einstiegspunkt muss definiert werden.

Do you know why Matlab uses Visual C++ compiler, although MinGW C++ is configured?