我正在ROS2中构建一个程序包。当我想在头文件中包含动态库qpOASES时发生undefined reference to
错误。
qpOASES安装在~
下。
我尝试了find_package(qpOASES REQUIRED)
。但是我得到了错误
By not providing "FindqpOASES.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "qpOASES", but CMake did not find one.
在头文件中,我使用
#include <qpOASES.hpp>
。在CMakeList.txt文件中,我使用target_link_libraries(my_node Eigen3::Eigen ~/qpOASES-3.2.1/bin/libqpOASES.so)
。但是当我编译它时,出现以下错误。ltv_mpc_controller.cpp:(.text+0x4a07): undefined reference to `qpOASES::SQProblem::SQProblem(int, int, qpOASES::HessianType, qpOASES::BooleanType)'
ltv_mpc_controller.cpp:(.text+0x4a7b): undefined reference to `qpOASES::QProblem::init(double const*, double const*, double const*, double const*, double const*, double const*, double const*, int&, double*, double const*, double const*, qpOASES::Bounds const*, qpOASES::Constraints const*, double const*)'
ltv_mpc_controller.cpp:(.text+0x4aeb): undefined reference to `qpOASES::SQProblem::hotstart(double const*, double const*, double const*, double const*, double const*, double const*, double const*, int&, double*, qpOASES::Bounds const*, qpOASES::Constraints const*)'
有人知道如何解决此错误吗?
最佳答案
在第110行的Linux makefile make_linux.mk
中,有
CPPFLAGS = -Wall -pedantic -Wshadow -Wfloat-equal -O3 -Wconversion -Wsign-conversion -fPIC -DLINUX -D__USE_LONG_INTEGERS__ -D__USE_LONG_FINTS__
尝试删除标志
-D__USE_LONG_INTEGERS__ -D__USE_LONG_FINTS__
这为我解决了。
关于c++ - 使用动态库qpOASES和CMakeList.txt时对qpOASES错误的 undefined reference ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55620906/