我在这里有这段代码:
Main.cpp
#include "AStarPlanner.h"
#include <costmap_2d/costmap_2d.h>
int main(int argc, char** argv)
{
AStarPlanner planner = AStarPlanner(10,10,&costmap);
}
和我的班级:
AStarPlanner.h
class AStarPlanner {
public:
AStarPlanner(int width, int height, const costmap_2d::Costmap2D* costmap);
virtual ~AStarPlanner();
AStarPlanner.cpp
#include "AStarPlanner.h"
using namespace std;
AStarPlanner::AStarPlanner(int width, int height, const costmap_2d::Costmap2D* costmap)
{
ROS_INFO("Planner Konstruktor");
width_ = width;
height_ = height;
costmap_ = costmap;
}
我看不出我有任何错误。该函数已定义,我的 main.cpp 知道该类。
制作清单
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_library (robot_mover src/AStarPlanner.cpp )
rosbuild_add_executable(robot_mover src/main.cpp)
但我收到此错误:
未定义对vtable for AStarPlanner'**
** undefined reference to
AStarPlanner::~AStarPlanner()' 的引用