/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} )