MATLAB c_generated_code fails at make command

Hello,
I have installed ACADOS with python and MATLAB interfaces just fine.

Now I am trying the Linear MPC example in the MATLAB interface which works as expected with the c_generated_code and the MATLAB plots working.

The problem arises when I go to the c_generated_code directory and run the make command. It ends with the following error:

/usr/bin/ld: warning: libqpOASES_e.so.3.1, needed by /home/sn/acados/lib/libacados.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libdaqp.so, needed by /home/sn/acados/lib/libacados.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libosqp.so, needed by /home/sn/acados/lib/libacados.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `osqp_update_P_A'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `update_ldp'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblem_init'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemB_setPrintLevel'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblem_hotstart'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemB_assignMemory'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `deactivate_constraints'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblem_setPrintLevel'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblem_getDualSolution'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `ldp2qp_solution'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `set_rho_vec'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemB_init'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `OptionsCPY'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemB_hotstart'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `Options_setToMPC'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `osqp_update_lin_cost'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `cold_start'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemB_printProperties'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblem_initW'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `update_status'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `osqp_update_bounds'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `scale_data'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `load_linsys_solver'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblem_getPrimalSolution'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemB_getPrimalSolution'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `daqp_default_settings'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblem_calculateMemorySize'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemB_getDualSolution'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemB_calculateMemorySize'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblem_assignMemory'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemCON'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemBCON'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `Options_ensureConsistency'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `osqp_set_default_settings'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblemB_initW'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `QProblem_printProperties'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `init_linsys_solver'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `daqp_ldp'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `activate_constraints'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `osqp_solve'
/usr/bin/ld: /home/sn/acados/lib/libacados.so: undefined reference to `print_setup_header'
collect2: error: ld returned 1 exit status
make: *** [Makefile:119: example] Error 1

Before running MATLAB I used:

export ACADOS_INSTALL_DIR="/home/sn/acados"

What could be the issue?

Thanks

EDIT:

I get the same problem with the python interface in the getting_started example. running make (after source env/bin/activate) gives the same issue

EDIT2:

Solved for PYTHON I have to run the export variables each time

I think I have to run the following in the c_generated_code dir first:
mkdir -p build
cmake … (with desired options)
and then run make in the build directory?

The problem was I had to close MATLAB and run the cmake … and make commands from the same terminal