Cannot execute minimal_example_ocp in matlab2023a in Windows10

I’m using acados with matlab2023a in Win10.
After automatic building of acados (minGW) following the guide in Installation — acados documentation , I run minimal_example_ocp and get the following Error:

--------------------------------------------------------------
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
 
found compiled acados MEX interface
Successfully rendered acados templates!
Error using: acados_template_mex.compile_ocp_shared_lib
Building templated code as shared library failed.
Got status 2, result: [ 14%] Building C object
CMakeFiles/model_pendulum.dir/pendulum_model/pendulum_expl_ode_fun.c.obj
[ 28%] Building C object
CMakeFiles/model_pendulum.dir/pendulum_model/pendulum_expl_vde_forw.c.obj
[ 42%] Building C object
CMakeFiles/model_pendulum.dir/pendulum_model/pendulum_expl_vde_adj.c.obj
[ 42%] Built target model_pendulum
[ 57%] Building C object
CMakeFiles/ocp_pendulum.dir/pendulum_constraints/pendulum_constr_h_0_fun_jac_uxt_zt.c.obj
[ 71%] Building C object
CMakeFiles/ocp_pendulum.dir/pendulum_constraints/pendulum_constr_h_0_fun.c.obj
[ 85%] Building C object
CMakeFiles/ocp_pendulum.dir/acados_solver_pendulum.c.obj
[ 85%] Built target ocp_pendulum
[100%] Linking C shared library acados_ocp_solver_pendulum.dll
D:/acados/acados/examples/acados_matlab_octave/../../lib/acados.lib(timing.c.obj):timing.c:(.text+0x22):
undefined reference to `clock_gettime'
D:/acados/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
mingw32-make.exe[2]: ***
[CMakeFiles\acados_ocp_solver_pendulum.dir\build.make:94:
acados_ocp_solver_pendulum.dll] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:139:
CMakeFiles/acados_ocp_solver_pendulum.dir/all] Error 2
mingw32-make.exe: *** [Makefile:135: all] Error 2


Error: ocp_generate_c_code (第 281 行)
    acados_template_mex.compile_ocp_shared_lib(obj.acados_ocp_nlp_json.code_export_directory)

Error: acados_ocp (第 203 行)
            ocp_generate_c_code(obj);

Error: minimal_example_ocp (第 114 行)
ocp = acados_ocp(ocp_model, ocp_opts, simulink_opts);
 

Could you figure out how to fix it?
Thank you

Hi,

clock_gettime should work on any modern system out of the box: linux - C++ error: undefined reference to 'clock_gettime' and 'clock_settime' - Stack Overflow

Although there seems to have been some issue with that timer and MinGW: Bug #1853168 “undefined reference to `clock_gettime'” : Bugs : EPICS Base

Could you try to find what MinGW version you have?

Also you could edit timing.c and timing.h to just return 0, if you want to use acados without timings.

Best,
Jonathan

Hi,

a similar problem is reported here and is likely an issue of (some) mingw versions:

@yuhai, could you provide your version of MinGW?