码迷,mamicode.com
首页 > 其他好文 > 详细

A namespace下使用B namespace 中的类:error undefined type

时间:2018-03-02 23:55:31      阅读:321      评论:0      收藏:0      [点我收藏+]

标签:ack   lists   rect   class   连接   ble   mini   end   opencv   

/home/zhanghu/catkin_ws/src/map_img_proccess/src/main.cpp:9:3: error:‘key_data_collect’ has not been declared
   key_data_collect::collect my_collect("/laser_scan","/amcl_pose","/keypoint_scan","/home/zhanghu/1.test.yaml","/home/zhanghu/1.test.pgm");
   ^
/home/zhanghu/catkin_ws/src/map_img_proccess/src/main.cpp:9:29: error: expected ‘;’ before ‘my_collect’
   key_data_collect::collect my_collect("/laser_scan","/amcl_pose","/keypoint_scan","/home/zhanghu/1.test.yaml","/home/zhanghu/1.test.pgm");

原因:
CMake link错误,工程中库的连接关系是:
main--->key_data_collect--->map_img_load
因为key_data_collect使用了map_img_load库中的内容,所以key_data_collect库编译时需要linkmap_img_load库

解决办法:
[CMakeLists.txt]:
cmake_minimum_required(VERSION 2.8.3)
project(map_img_proccess)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  sensor_msgs
  geometry_msgs
  tf
  message_filters
)

find_package(OpenCV REQUIRED)

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES map_img_load key_data_collect
#  CATKIN_DEPENDS roscpp
#  DEPENDS system_lib
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)


#lib map_img_load
add_library(map_img_load src/map_img_load.cpp)
target_link_libraries(map_img_load ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
#lib key_data_collect
add_library(key_data_collect src/key_data_collect.cpp)
target_link_libraries(key_data_collect map_img_load ${catkin_LIBRARIES} )
#exe main
add_executable(main src/main.cpp)
target_link_libraries(main key_data_collect ${catkin_LIBRARIES} )

A namespace下使用B namespace 中的类:error undefined type

标签:ack   lists   rect   class   连接   ble   mini   end   opencv   

原文地址:https://www.cnblogs.com/hiram-zhang/p/8495354.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!