実行時エラー

エラー内容

[mpc_path_planning-17] CasADi - 2023-01-19 21:10:35 WARNING(".../casadi/core/plugin_interface.hpp:322: Assertion "handle!=nullptr" failed:
[mpc_path_planning-17] PluginInterface::load_plugin: Cannot load shared library 'libcasadi_nlpsol_ipopt.so': 
[mpc_path_planning-17]    (
[mpc_path_planning-17]     Searched directories: 1. casadipath from GlobalOptions
[mpc_path_planning-17]                           2. CASADIPATH env var
[mpc_path_planning-17]                           3. PATH env var (Windows)
[mpc_path_planning-17]                           4. LD_LIBRARY_PATH env var (Linux)
[mpc_path_planning-17]                           5. DYLD_LIBRARY_PATH env var (osx)
[mpc_path_planning-17]     A library may be 'not found' even if the file exists:
[mpc_path_planning-17]           * library is not compatible (different compiler/bitness)
[mpc_path_planning-17]           * the dependencies are not found
[mpc_path_planning-17]    )
[mpc_path_planning-17]   Tried '' :
[mpc_path_planning-17]     Error code: libcasadi_nlpsol_ipopt.so: cannot open shared object file: No such file or directory
[mpc_path_planning-17]   Tried '.' :
[mpc_path_planning-17]     Error code: ./libcasadi_nlpsol_ipopt.so: cannot open shared object file: No such file or directory") [.../casadi/core/plugin_interface.hpp:171]

解決方法

インストール時に以下のオプションを有効にする

cmake -DWITH_IPOPT=true ..

CMakeLists.txtの場合

cmake_minimum_required(VERSION 3.5)

project(casadi_ament)

find_package(ament_cmake REQUIRED)

include(ExternalProject)
ExternalProject_Add(casadi
  GIT_REPOSITORY  <https://github.com/casadi/casadi.git>
  GIT_TAG         master
  CMAKE_ARGS
    -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/casadi_install
    -DWITH_IPOPT=true #これを追加
)

install(
  DIRECTORY   ${CMAKE_CURRENT_BINARY_DIR}/casadi_install/
  DESTINATION ${CMAKE_INSTALL_PREFIX}
)

ament_export_include_directories(include)
ament_export_libraries(casadi)
ament_package()

https://github.com/casadi/casadi/issues/2521