/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
Posted hiram-zhang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了A namespace下使用B namespace 中的类:error undefined type相关的知识,希望对你有一定的参考价值。
以上是关于A namespace下使用B namespace 中的类:error undefined type的主要内容,如果未能解决你的问题,请参考以下文章