Compiling Error for MicroAutoBox III

Hi :wave:

I am using Matlab 2023b together with the dSPACE release 2024A and a MicroAutoBox III. I followed the steps for dSPACE DS1401 and DS1403 in the ACADOS Embedded Workflow.

As already mentioned by an other thread (Compiling Acados for Microautobox 3) I replaced the -J with a -I in the Toolchain-dSpaceDS1403.cmake file.

Calling: cmake -D CMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-dSPACEDS1401.cmake -G "Unix Makefiles" -S ../ -B ./ works fine.

When calling cmake --build ./ everything runs through successfully, however, I receive some warnings during certain building steps (78%, 89%, 90%, 96%):

'[ 78%] Building C object acados/CMakeFiles/acados.dir/dense_qp/dense_qp_hpipm.c.obj
C:/Users/Kn/Documents/GitLab/acados/acados/dense_qp/dense_qp_hpipm.c:299:9: warning: implicit declaration of function 'd_print_exp_tran_mat' [-Wimplicit-function-declaration]
  299 |         d_print_exp_tran_mat(stat_m, mem->iter+1, stat, stat_m);
      |         ^~~~~~~~~~~~~~~~~~~~
[ 79%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_common.c.obj
[ 79%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_constraints_bgh.c.obj
[ 80%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_constraints_bgp.c.obj
[ 80%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_constraints_common.c.obj
[ 81%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_cost_common.c.obj
[ 81%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_cost_conl.c.obj
[ 82%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_cost_external.c.obj
[ 82%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_cost_ls.c.obj
[ 83%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_cost_nls.c.obj
[ 83%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_ddp.c.obj
[ 84%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_dynamics_common.c.obj
[ 84%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_dynamics_cont.c.obj
[ 85%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_dynamics_disc.c.obj
[ 85%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_reg_common.c.obj
[ 86%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_reg_convexify.c.obj
[ 86%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_reg_mirror.c.obj
[ 87%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_reg_noreg.c.obj
[ 87%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_reg_project.c.obj
[ 88%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_reg_project_reduc_hess.c.obj
[ 88%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_sqp.c.obj
[ 89%] Building C object acados/CMakeFiles/acados.dir/ocp_nlp/ocp_nlp_sqp_rti.c.obj
C:/Users/Kn/Documents/GitLab/acados/acados/ocp_nlp/ocp_nlp_sqp_rti.c: In function 'ocp_nlp_sqp_rti_feedback_step':
C:/Users/Kn/Documents/GitLab/acados/acados/ocp_nlp/ocp_nlp_sqp_rti.c:650:46: warning: 'qp_status' may be used uninitialized [-Wmaybe-uninitialized]
  650 |     mem->stat[mem->stat_n * mem->sqp_iter+0] = qp_status;
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
C:/Users/Kn/Documents/GitLab/acados/acados/ocp_nlp/ocp_nlp_sqp_rti.c:558:9: note: 'qp_status' was declared here
  558 |     int qp_status, line_search_status;
      |         ^~~~~~~~~
[ 89%] Building C object acados/CMakeFiles/acados.dir/ocp_qp/ocp_qp_common.c.obj
[ 89%] Building C object acados/CMakeFiles/acados.dir/ocp_qp/ocp_qp_common_frontend.c.obj
[ 90%] Building C object acados/CMakeFiles/acados.dir/ocp_qp/ocp_qp_full_condensing.c.obj
[ 90%] Building C object acados/CMakeFiles/acados.dir/ocp_qp/ocp_qp_hpipm.c.obj
C:/Users/Kn/Documents/GitLab/acados/acados/ocp_qp/ocp_qp_hpipm.c: In function 'ocp_qp_hpipm':
C:/Users/Kn/Documents/GitLab/acados/acados/ocp_qp/ocp_qp_hpipm.c:329:9: warning: implicit declaration of function 'd_print_exp_tran_mat' [-Wimplicit-function-declaration]
  329 |         d_print_exp_tran_mat(stat_m, mem->iter+1, stat, stat_m);
      |         ^~~~~~~~~~~~~~~~~~~~
[ 91%] Building C object acados/CMakeFiles/acados.dir/ocp_qp/ocp_qp_partial_condensing.c.obj
[ 91%] Building C object acados/CMakeFiles/acados.dir/ocp_qp/ocp_qp_xcond_solver.c.obj
[ 92%] Building C object acados/CMakeFiles/acados.dir/sim/sim_collocation_utils.c.obj
[ 92%] Building C object acados/CMakeFiles/acados.dir/sim/sim_common.c.obj
[ 93%] Building C object acados/CMakeFiles/acados.dir/sim/sim_erk_integrator.c.obj
[ 93%] Building C object acados/CMakeFiles/acados.dir/sim/sim_gnsf.c.obj
[ 94%] Building C object acados/CMakeFiles/acados.dir/sim/sim_irk_integrator.c.obj
[ 94%] Building C object acados/CMakeFiles/acados.dir/sim/sim_lifted_irk_integrator.c.obj
[ 95%] Building C object acados/CMakeFiles/acados.dir/utils/external_function_generic.c.obj
[ 95%] Building C object acados/CMakeFiles/acados.dir/utils/math.c.obj
[ 96%] Building C object acados/CMakeFiles/acados.dir/utils/mem.c.obj
[ 96%] Building C object acados/CMakeFiles/acados.dir/utils/print.c.obj
C:/Users/Kn/Documents/GitLab/acados/acados/utils/print.c:563:13: warning: 'int_print_mat_to_file' defined but not used [-Wunused-function]
  563 | static void int_print_mat_to_file(FILE *file, int row, int col, int *A, int lda)
      |             ^~~~~~~~~~~~~~~~~~~~~
[ 97%] Building C object acados/CMakeFiles/acados.dir/utils/timing.c.obj
[ 98%] Building C object acados/CMakeFiles/acados.dir/__/interfaces/acados_c/ocp_nlp_interface.c.obj
[ 99%] Building C object acados/CMakeFiles/acados.dir/__/interfaces/acados_c/ocp_qp_interface.c.obj
[ 99%] Building C object acados/CMakeFiles/acados.dir/__/interfaces/acados_c/condensing_interface.c.obj
[100%] Building C object acados/CMakeFiles/acados.dir/__/interfaces/acados_c/sim_interface.c.obj
[100%] Linking C static library libacados.a
[100%] Built target acados

cmake --install ./ works fine.

In Simulink I added:

"...\acados\buildDS1403\install\include"
"...\acados\buildDS1403\install\include\blasfeo\include"
"...\acados\buildDS1403\install\include\hpipm\include"

to the ā€œinclude directoriesā€ and:

"...\acados\buildDS1403\install\lib\libacados.a"
"...\acados\buildDS1403\install\lib\libblasfeo.a"
"...\acados\buildDS1403\install\lib\libhpipm.a"

to the ā€œLibrariesā€ (ending is .a instead of .lib, for whatever reason).

The source files I added are all files in make_sfun.m and make_sfun_sim.m. except for S-functions acados_solver_sfunction_{...}.c and acados_sim_solver_sfunction_{...}.c, because in this topic Building Issue ConfigurationDesk 2022-A - #3 by soeren it was mentioned that they should not be added.

When I build the Simulink model in ConfigurationDesk I receive the following error:

Making library "dSPACE_HyFCD_MPC.a" finished
Creating application image file ...
C:/Program Files/Common Files/dSPACE/CFD Compiler 24.1/target/arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/13.2.0/../../../../arm-linux-gnueabihf/bin/ld.exe: C:\Users\Kn\Documents\GitLab\acados\buildDS1403\install\lib\libacados.a(dense_qp_hpipm.c.obj): in function `dense_qp_hpipm':
dense_qp_hpipm.c:(.text+0x2cc): undefined reference to `d_print_exp_tran_mat'
C:/Program Files/Common Files/dSPACE/CFD Compiler 24.1/target/arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/13.2.0/../../../../arm-linux-gnueabihf/bin/ld.exe: C:\Users\Kn\Documents\GitLab\acados\buildDS1403\install\lib\libacados.a(ocp_qp_hpipm.c.obj): in function `ocp_qp_hpipm':
ocp_qp_hpipm.c:(.text+0x32c): undefined reference to `d_print_exp_tran_mat'
collect2.exe: error: ld returned 1 exit status
OPUS MAKE: Shell line exit status 1. Stop.
The make phase failed for the following application process: dSPACE_HyFCD_MPC.
==== Build Summary =============================================================
Application process                      Build time           Status
--------------------------------------------------------------------------------
dSPACE_HyFCD_MPC                         00:00:06             Failed
--------------------------------------------------------------------------------
TOTAL                                    00:00:03             FAILED
--------------------------------------------------------------------------------
==== Build process aborted =====================================================

This might have something to do with the warning I receive during the Cmake build process

warning: implicit declaration of function 'd_print_exp_tran_mat' [-Wimplicit-function-declaration]
  329 |         d_print_exp_tran_mat(stat_m, mem->iter+1, stat, stat_m);

because in both d_print_exp_tran_mat is mentioned.

Thanks for the support.

Jannis

Hi Jannis!

I havenā€™t had any such problems, so I wouldnā€™t have a ready solution to give you.

The only things I would recommend to try to solve the problem are the following:

  1. Have you included all the .c files autogenerated in the ā€œc_generated_codeā€ and subfolders? It should be included their path into the ā€œSources fileā€ of simulink.

  2. Try to find where the function is defined, and check if any inclusion is missing.

I hope it is helpful.

Ciao!

Samuele

Hi @Jannis

sorry for the inconvenience!
It seems like we added some prints that broke compilation with the EXT_DEP=OFF option.
I started a branch here where the acados related issues are fixed but there are still issues with HPIPM.

Please feel free to try and let me know if this already fixes it for you.

Best,
Jonathan

Hi Jonathan,

thank you for the quick fix, that seems to have solved the Issue I was facing. The MPC can now be successfully build and downloaded onto the MicroAutoBox III :partying_face:.

However, I still have some open questions regarding the Embedded Workflow:

  1. During the build process only the solver hpipm is available after cross-compiling. What do I need to adapt in the Embedded Workflow to use other solvers, for example qpOASIS?
  2. After cross-Compiling I can now longer generate code from my model, or any other model (like the minimal_example_ocp.m). I always get this error:

Error using mex MEX cannot find library 'acados', specified with the -l option. MEX searched for a file with one of the following names: libacados.a acados.lib libacados.lib Verify the library name is correct. If the library is not on the existing path, specify the path with the -L option

Is this normal after cross-compiling? If I want to rebuild my model do I need to reinstall ACADOS in a seperate folder?

  1. Will this fix be pushed to main anytime soon?

I also think that the Embedded Workflow needs to be slightly updated to work with newer dSPACE releases. If you like I can make a suggestion for the update.

Thanks for your help

Jannis

Hi Jannis,

On point 1:
I think you just need to also set the appropriate flags when cross compiling, such as -DACADOS_WITH_QPOASES=OFF. However more solvers can of course mean more compilation problems.

On point 2:
I think if you cross-compile into a different folder (not acados/build and acados/lib) this should not be an issue.
Also check if the file acados/lib/link_libs.json gets overwritten by the cross-compilation. Maybe this needs to be fixed.

  1. this fix be pushed to main anytime soon?

I want to make some tests to also test compilation with EXT_DEP=OFF on Github which takes a bit of time. But will try to get it merged soon.

Best,
Jonathan