acados / acados

Fast and embedded solvers for nonlinear optimal control
Other
825 stars 251 forks source link

Python CMakeBuilder results in Linker errors when using different QP solvers #904

Closed spenrich closed 1 year ago

spenrich commented 1 year ago

I'm on Linux (Ubuntu 22.04). I've installed Acados via cmake with the command:

cmake -DACADOS_WITH_OSQP=ON -DACADOS_WITH_QPOASES=ON -DACADOS_WITH_OPENMP=ON ..

I've added the following to my .zshrc file:

export ACADOS_SOURCE_DIR="$HOME/src/acados"
export LD_LIBRARY_PATH="$ACADOS_SOURCE_DIR/lib:$LD_LIBRARY_PATH"

I installed the Python interface and successfully ran the example minimal_example_ocp_cmake.py. However, if I change the QP solver on this line to use FULL_CONDENSING_QPOASES, I get the following output with linker errors:

python minimal_example_ocp_cmake.py
call("cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/home/spenrich/src/acados/examples/acados_python/pendulum_on_cart/ocp/c_generated_code" -DBUILD_ACADOS_OCP_SOLVER_LIB=ON -Wdev -S"/home/spenrich/src/acados/examples/acados_python/pendulum_on_cart/ocp/c_generated_code" -B"/home/spenrich/src/acados/examples/acados_python/pendulum_on_cart/ocp/c_generated_code/build")"
-- Configuring done
-- Generating done
-- Build files have been written to: /home/spenrich/src/acados/examples/acados_python/pendulum_on_cart/ocp/c_generated_code/build
call("cmake --build "/home/spenrich/src/acados/examples/acados_python/pendulum_on_cart/ocp/c_generated_code/build" --config Release -j32")
Consolidate compiler generated dependencies of target model_pendulum_ode
Consolidate compiler generated dependencies of target ocp_pendulum_ode
[ 25%] Building C object CMakeFiles/model_pendulum_ode.dir/pendulum_ode_model/pendulum_ode_expl_ode_fun.c.o
[ 50%] Building C object CMakeFiles/model_pendulum_ode.dir/pendulum_ode_model/pendulum_ode_expl_vde_forw.c.o
[ 75%] Building C object CMakeFiles/ocp_pendulum_ode.dir/acados_solver_pendulum_ode.c.o
<command-line>: warning: ISO C99 requires whitespace after the macro name
<command-line>: warning: ISO C99 requires whitespace after the macro name
<command-line>: warning: ISO C99 requires whitespace after the macro name
[ 75%] Built target model_pendulum_ode
[ 75%] Built target ocp_pendulum_ode
[100%] Linking C shared library libacados_ocp_solver_pendulum_ode.so
/usr/bin/ld: CMakeFiles/ocp_pendulum_ode.dir/acados_solver_pendulum_ode.c.o: warning: relocation against `stderr@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: CMakeFiles/ocp_pendulum_ode.dir/acados_solver_pendulum_ode.c.o: relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
gmake[2]: *** [libacados_ocp_solver_pendulum_ode.so] Error 1
gmake[1]: *** [CMakeFiles/acados_ocp_solver_pendulum_ode.dir/all] Error 2
gmake: *** [all] Error 2
Execution failed: Build command "cmake --build "/home/spenrich/src/acados/examples/acados_python/pendulum_on_cart/ocp/c_generated_code/build" --config Release -j32" was terminated by signal 2

I get similar errors when I try PARTIAL_CONDENSING_OSQP instead. Any idea why this is happening? This may be related to #651, but I'm not sure.

spenrich commented 1 year ago

Interestingly, the example time_optimal_example.py, which uses FULL_CONDENSING_QPOASES here and also the Cython wrapper, seems to work fine.

spenrich commented 1 year ago

Thank you!