我的代码有问题。它正在运行,但是当我决定将其拆分为多个文件时,出现链接错误。
我在寻找其他类似的帖子,但仍然找不到问题所在。 这是我的代码:
.h
#ifndef VALIDITYCHECKER_H
#define VALIDITYCHECKER_H
//#including various libraries ...
namespace ob = ompl::base;
class ValidityChecker : public ob::StateValidityChecker
{
public:
ValidityChecker(const ob::SpaceInformationPtr& si) :
ob::StateValidityChecker(si) {}
bool isValid(const ob::State* state) const override
{
return this-> clearance(state) > 0.0;
}
double clearance(const ob::State* state) const override;
};
#endif
.cpp
#include "push_optimal_planner/validitychecker.h"
namespace ob = ompl::base;
namespace og = ompl::geometric;
double clearance(const ob::State* state)
{ //some code for the function }
我收到此错误:
CMakeFiles/planning.dir/src/planning.cpp.o: nella funzione "ValidityChecker::ValidityChecker(std::shared_ptr<ompl::base::SpaceInformation> const&)":
/home/simone/catkin_ws/src/push_optimal_planner/include/push_optimal_planner/validitychecker.h:44: riferimento non definito a "vtable for ValidityChecker"
collect2: error: ld returned 1 exit status
(“ riferimento non definito a'vtable”的意大利语,表示:“对`vtable的未定义引用”)