Error during runing the example in Matlab 2019b

Hi, I was following the installation instructions to run the example with Matlab 2019b on Win 10. Then I met the following errors. Could you please help me to solve the problem? Thanks!

>> minimal_example_ocp

ans = 

  acados_ocp_opts with properties:

    opts_struct: [1×1 struct]

--------------------------------------------------------------
Structure detection for path cost
Cost function is quadratic -> Reformulating as linear_ls cost.


reformulated cost term in linear least squares form with:
cost = 0.5 * || Vx * x + Vu * u + Vz * z - y_ref ||_W

Vx
     1     0     0     0
     0     1     0     0
     0     0     1     0
     0     0     0     1
     0     0     0     0


Vu
     0
     0
     0
     0
     1


Vz

W
   1.0e+03 *

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    0.0000         0         0
         0         0         0    0.0000         0
         0         0         0         0    0.0000


y_ref
     0
     0
     0
     0
     0


y (symbolic)
[p, theta, v, dtheta, F]

NOTE: These numerical values can be updated online using the appropriate setters.
--------------------------------------------------------------
--------------------------------------------------------------
Structure detection for terminal cost term
Cost function is quadratic -> Reformulating as linear_ls cost.


reformulated cost term in linear least squares form with:
cost = 0.5 * || Vx * x + Vu * u + Vz * z - y_ref ||_W

Vx
     1     0     0     0
     0     1     0     0
     0     0     1     0
     0     0     0     1


Vu
     0
     0
     0
     0


Vz

W
   1.0e+03 *

    1.0000         0         0         0
         0    1.0000         0         0
         0         0    0.0000         0
         0         0         0    0.0000


y_ref
     0
     0
     0
     0


y (symbolic)
[p, theta, v, dtheta]

NOTE: These numerical values can be updated online using the appropriate setters.
--------------------------------------------------------------

Constraint detection for path constraints.
constraint 1 is reformulated as bound on u.
F
 
compiling D:\acados\examples\acados_matlab_octave\..\..\interfaces\acados_matlab_octave\ocp_get_cost.c
Building with 'MinGW64 Compiler (C)'.
Error using mex
D:\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(timing.c.obj):timing.c:(.text+0x22): undefined
reference to `clock_gettime'
D:\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(timing.c.obj):timing.c:(.text+0x9): undefined
reference to `clock_gettime'
collect2.exe: error: ld returned 1 exit status


Error in ocp_compile_interface (line 141)
        mex(mex_flags, FLAGS, LDFLAGS, COMPDEFINES, COMPFLAGS, acados_include, acados_interfaces_include,
        external_include, blasfeo_include, hpipm_include,...

Error in acados_ocp (line 184)
                ocp_compile_interface(obj.opts_struct);

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

Thanks for reporting :wave:

This looks like the issue reported here and is likely an issue of (some) mingw versions:

Could you provide your version of MinGW?

Hi, my MinGW version is 6.3.

Hello,

I encountered the same problem on Windows 10 with MATLAB 2020b, update 8. Interestingly, on another machine with Windows 10, but with MATLAB 2020b, update 7, acados is running fine. Not sure if it’s only due to the MATLAB update or something else as well.

MinGW is identical in both versions, also 6.3.0.

I’m not too familiar with the compilation process, but it seems to me that this section is run instead of this one. Perhaps that is the correct execution path.

I managed to solve it by modifying the acados_tic and acados_toc functions to avoid calling clock_gettime.
Copying this section instead of this and this section instead of this works for me and enables (hopefully correct) timings :slight_smile:

Kind regards,
Josip

2 Likes

Hi Josip,

thanks for posting your solution.
Of course, we do not want to replace the ANSI C mode timing.
But if the Windows timing works also when using MinGW, I guess we should just remove the last part of the following condition:

#if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__)

and change it to read:

#if (defined _WIN32 || defined _WIN64).

Do you think that makes sense?

Best,
Jonathan

Hi Jonathan,

yes, that seems like a much nicer way to do it :slight_smile:
I wasn’t sure exactly which section should be used so decided to modify the ANSI C one…

If needed, I can test the suggested modification (on the problematic machine) in the beginning of next week at the latest.

Best regards,
Josip

Awesome, yes that is highly appreciated!

No problem :slight_smile:
A PR implementing the suggested change is here.