动态链接库 (.so)调用问题;类变量定义

使用方式:需要在一个包去调用另一个包

global_planner::hybrid_astar hy1;

问题:

Failed to create the rrt_plan/rrt_planner planner, are you sure it is properly registered and that the containing library is built? Exception: Failed to load library /home/like/c++/catkin_rrt/devel/lib//librrt_lib.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = /home/like/c++/catkin_rrt/devel/lib//librrt_lib.so: undefined symbol: _ZN14global_planner12hybrid_astarC1Ev) 

库调用不正确/librrt_lib.so没有调用

解决方式:

1)  target_link_libraries(rrt_lib ${catkin_LIBRARIES} base_local_planner)

当我们使用其他的库的时候,需要加上上面的这句命令去调用其他的库 rrb_lib是自己生成的库 

  ${catkin_LIBRARIES} 是我们这个包里面去调用其他的库 

base_local_planner 这个可加可不加,,上面的命令会全部加入所需要的库

2) 重定义的变量中的构造函数变量的库没有调用 (下面是我的构造函数)

hybrid_astar::hybrid_astar():
  costmap_(NULL),lethal_cost(253), neutral_cost(50),
  convert_offset_(0.5),cx(4846),cy(2816),resolution(0.298582141738734),
  origin_x(0),origin_y(0)
{
    p_calc = new PotentialCalculator(cx, cy);//声明对象
    planner_ = new DijkstraExpansion(p_calc, cx, cy);//声明调用这个规划的基类
    potential_array_ = new float[cx * cy];

    planner_->setHasUnknown(true);
    planner_->setLethalCost(lethal_cost);
    planner_->setNeutralCost(neutral_cost);
    DijkstraExpansion dijkstra(PotentialCalculator* p_calc, int cx, int cy);//定义一个dijistra变量
    rs_publisher = rs_n.advertise<nav_msgs::Path>("/reedsshepp/plan", 1);

}

修改:

hybrid_astar::hybrid_astar():
  costmap_(NULL),lethal_cost(253), neutral_cost(50),
  convert_offset_(0.5),cx(4846),cy(2816),resolution(0.298582141738734),
  origin_x(0),origin_y(0)
{
    rs_publisher = rs_n.advertise<nav_msgs::Path>("/reedsshepp/plan", 1);

}

猜你喜欢

转载自blog.csdn.net/qq_31815513/article/details/85043944