Mex error running the examples (Windows)

Hi :wave:

Windows 11, Matlab 2021a

I installed today acados following the installation procedure “Installation — acados documentation” without problems but as soon as I run the examples in \examples\acados_matlab_octave\getting_started I receive the following error:

Error using mex
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_nlp_common.c.obj):ocp_nlp_common.c:(.text+0x2a):
undefined reference to `__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_nlp_reg_common.c.obj):ocp_nlp_reg_common.c:(.text+0x25):
undefined reference to `__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_xcond_solver.c.obj):ocp_qp_xcond_solver.c:(.text+0x725):
undefined reference to `__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(sim_common.c.obj):sim_common.c:(.text+0x2a): undefined
reference to `__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(math.c.obj):math.c:(.text+0x25): undefined reference to
`__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(timing.c.obj):timing.c:(.text+0x22): undefined
reference to `__pthread_clock_gettime'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(timing.c.obj):timing.c:(.text+0x9): undefined reference
to `__pthread_clock_gettime'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_nlp_interface.c.obj):ocp_nlp_interface.c:(.text+0x2a):
undefined reference to `__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_interface.c.obj):ocp_qp_interface.c:(.text+0x2a):
undefined reference to `__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_hpipm.c.obj):dense_qp_hpipm.c:(.text+0x425):
undefined reference to `__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_nlp_constraints_bgh.c.obj):ocp_nlp_constraints_bgh.c:(.text+0x42a):
undefined reference to `__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_nlp_constraints_bgp.c.obj):ocp_nlp_constraints_bgp.c:(.text+0x40a):
undefined reference to `__imp___acrt_iob_func'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_nlp_cost_external.c.obj):ocp_nlp_cost_external.c:(.text+0x2fa):
more undefined references to `__imp___acrt_iob_func' follow
collect2.exe: error: ld returned 1 exit status


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

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

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

I know that this same problem has already be treated regarding MacOS, but despite the changes made to the code I experienced the same problem.

Thanks for your support!
Gianmarco.

Hi Gianmarco,

I think you didn’t paste the full error message.
The essential part should be above the lines you posted.

I just edited the error with the full one, thanks!

Are you sure that you use the same compiler in MEX and for compiling the acados lib?
Please double check this.

It is not clear to me how to check this.

I installed using add-ons manager MATLAB Support for MinGW-w64 C/C++ Compiler.
On the command windows I obtain:

>>mex -setup C
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.

I following the installation guide with the commands:

cmake.exe -G "MinGW Makefiles" -DACADOS_INSTALL_DIR="$ACADOS_INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF -DACADOS_WITH_OSQP=ON ..

and on the windows power shell

mingw32-make.exe -j4
mingw32-make.exe install

Do I have to install also a package at this link? Downloads - MinGW-w64

Thanks for your support!

I moved up the compiler path in the path list of the environment variables and re-installed everything. I obtained a new error, which I think it has already been treated but it’s not clear to me if it has been solved or not.
It is the following one:

compiling C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\interfaces\acados_matlab_octave\ocp_create.c
Building with 'MinGW64 Compiler (C)'.
Error using mex
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1e5): undefined reference to
`QProblem_calculateMemorySize'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x21a): undefined reference to
`QProblemB_calculateMemorySize'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x483): undefined reference to
`QProblemB_assignMemory'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x48b): undefined reference to
`QProblemB_calculateMemorySize'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x526): undefined reference to
`QProblem_assignMemory'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x530): undefined reference to
`QProblem_calculateMemorySize'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xa8e): undefined reference to
`QProblemBCON'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xa9b): undefined reference to
`QProblemB_setPrintLevel'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xaa3): undefined reference to
`QProblemB_printProperties'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xb0e): undefined reference to
`QProblemB_init'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xb2d): undefined reference to
`QProblemB_getPrimalSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xb38): undefined reference to
`QProblemB_getDualSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xe8b): undefined reference to
`QProblem_hotstart'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xeaa): undefined reference to
`QProblem_getPrimalSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xeb5): undefined reference to
`QProblem_getDualSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xee1): undefined reference to
`QProblemCON'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xeee): undefined reference to
`QProblem_setPrintLevel'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xef6): undefined reference to
`QProblem_printProperties'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xfb9): undefined reference to
`QProblem_initW'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1160): undefined reference to
`QProblemB_initW'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x11d6): undefined reference to
`QProblemB_hotstart'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x11e6): undefined reference to
`QProblemB_getPrimalSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x11f1): undefined reference to
`QProblemB_getDualSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1273): undefined reference to
`QProblem_init'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1292): undefined reference to
`QProblem_getPrimalSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x129d): undefined reference to
`QProblem_getDualSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x12ae): undefined reference to
`Options_setToMPC'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x12fa): undefined reference to
`OptionsCPY'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1302): undefined reference to
`Options_ensureConsistency'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1315): undefined reference to
`QProblem_setPrintLevel'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x15d1): undefined reference to
`Options_setToMPC'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x161d): undefined reference to
`OptionsCPY'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1625): undefined reference to
`Options_ensureConsistency'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1638): undefined reference to
`QProblemB_setPrintLevel'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x168e): undefined reference to
`QProblem_initW'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x16d7): undefined reference to
`QProblemBCON'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x16e4): undefined reference to
`QProblemB_setPrintLevel'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x173b): undefined reference to
`QProblemB_init'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1755): undefined reference to
`QProblemB_getPrimalSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1760): undefined reference to
`QProblemB_getDualSolution'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x17b9): undefined reference to
`QProblem_init'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x17fa): undefined reference to
`QProblem_hotstart'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1828): undefined reference to
`QProblemCON'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x183a): undefined reference to
`QProblem_setPrintLevel'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x18bb): undefined reference to
`QProblem_init'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x18dd): undefined reference to
`Options_setToMPC'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1929): undefined reference to
`OptionsCPY'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1931): undefined reference to
`Options_ensureConsistency'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1944): undefined reference to
`QProblem_setPrintLevel'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1992): undefined reference to
`QProblem_init'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x19aa): undefined reference to
`Options_setToMPC'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x19fe): undefined reference to
`OptionsCPY'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1a0e): undefined reference to
`Options_ensureConsistency'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1a21): undefined reference to
`QProblem_setPrintLevel'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x4c): undefined reference to
`osqp_set_default_settings'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x1601): undefined reference to
`osqp_update_lin_cost'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x1630): undefined reference to
`osqp_update_P_A'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x1641): undefined reference to
`osqp_update_bounds'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x165a): undefined reference to
`osqp_solve'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x23ea): undefined reference to
`cold_start'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x258d): undefined reference to
`set_rho_vec'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x259c): undefined reference to
`load_linsys_solver'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x25d5): undefined reference to
`init_linsys_solver'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x262c): undefined reference to
`update_status'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x267f): undefined reference to
`print_setup_header'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x35ec): undefined reference to
`cold_start'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_osqp.c.obj):ocp_qp_osqp.c:(.text+0x3634): undefined reference to
`scale_data'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x2f0): undefined reference to
`qpDUNES_setupDefaultOptions'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x6f9): undefined reference to
`qpDUNES_setup'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x1170): undefined reference to
`qpDUNES_updateIntervalData'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x1ab1): undefined reference to
`qpDUNES_updateIntervalData'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x1b05): undefined reference to
`qpDUNES_solve'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x2780): undefined reference to
`qpDUNES_updateIntervalData'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x299b): undefined reference to
`qpDUNES_setupRegularInterval'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x2d2e): undefined reference to
`qpDUNES_setupFinalInterval'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x2d47): undefined reference to
`qpDUNES_setupAllLocalQPs'
C:\Users\ggran\acados\examples\acados_matlab_octave\..\..\lib\acados.lib(ocp_qp_qpdunes.c.obj):ocp_qp_qpdunes.c:(.text+0x3395): undefined reference to
`qpDUNES_cleanup'
collect2.exe: error: ld returned 1 exit status


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

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

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

Thanks for your help!

Is this just an issue with the external QP solvers (qpOASES, qpDUNES, OSQP)?
Can you try turning all of them off?

Do I repeat the installation procedure with:

cmake.exe -G "MinGW Makefiles" -DACADOS_WITH_OSQP=OFF -DACADOS_WITH_QPOASES=OFF -DACADOS_WITH_QPDUNES=OFF

or is there a faster way to change these flags?

Thanks!

Yes, that’s the way.
Ideally, you remove the contents of the build folder before doing this.
There is a CMakeCache.txt file inside.

Thanks a lot, it worked!