(catkin build)编译报错,找不到CASADI的头文件目录CASADI_INCLUDE_DIRS或者库文件也达不到CASADI_LIBRARIES;
对‘casadi::MX::horzsplit(casadi::MX const&, std::vector<long long, std::allocator<long long> > const&)’未定义的引用
对‘casadi::Sparsity::size2() const’未定义的引用
对‘casadi::MX::MX(casadi::MX const&)’未定义的引用
CMake Warning at /opt/ros/melodic/share/catkin/cmake/catkin_package.cmake:166 (message):
catkin_package() DEPENDS on 'CASADI' but neither 'CASADI_INCLUDE_DIRS' nor
'CASADI_LIBRARIES' is defined.
Call Stack (most recent call first):
/opt/ros/melodic/share/catkin/cmake/catkin_package.cmake:102 (_catkin_package)
CMakeLists.txt:38 (catkin_package)bit
/usr/bin/ld: warning: libopencv_core.so.2.4, needed by /usr/local/lib/libopencv_imgproc.so.2.4.13, may conflict with libopencv_core.so.3.2
/home/bit/planing_and_control_ws/devel/.private/path_smoothing/lib/libpath_smoothing.so:对‘casadi::MX::horzsplit(casadi::MX const&, std::vector<long long, std::allocator<long long> > const&)’未定义的引用
/home/bit/planing_and_control_ws/devel/.private/path_smoothing/lib/libpath_smoothing.so:对‘casadi::Sparsity::size2() const’未定义的引用
/home/bit/planing_and_control_ws/devel/.private/path_smoothing/lib/libpath_smoothing.so:对‘casadi::MX::MX(casadi::MX const&)’未定义的引用
解决方案:
先查找库文件的绝对路径:
sudo find | grep "libcasadi"
得到结果如下:
/usr/local/lib/libcasadi_integrator_rk.so.3.6
/usr/local/lib/libcasadi_linsol_symbolicqr.so.3.6
/usr/local/lib/libcasadi_rootfinder_nlpsol.so.3.6
。。。
。。。
/usr/local/lib/libcasadi_linsol_lsqr.so
/usr/local/lib/libcasadi_integrator_collocation.so.3.6
/usr/local/lib/libcasadi_integrator_rk.so
添加绝对路径到add_library()
add_library(xxx_node
#其他库
/usr/local/lib/libcasadi_integrator_rk.so.3.6
/usr/local/lib/libcasadi_linsol_symbolicqr.so.3.6
。。。
。。。
/usr/local/lib/libcasadi_linsol_lsqr.so
/usr/local/lib/libcasadi_integrator_collocation.so.3.6
/usr/local/lib/libcasadi_integrator_rk.so
)
参考:
安装casadi_大宝啊啊啊啊的博客-CSDN博客_matlab安装casadi
@meng