Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You have to change

add_executable(       class_node   src/class_node.cpp)
add_dependencies(     class_node   ${catkin_EXPORTED_TARGETS})
target_link_libraries(class_node   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

add_executable(       class_functions   src/class_functions.cpp)
add_dependencies(     class_functions   ${catkin_EXPORTED_TARGETS})
target_link_libraries(class_functions   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

either for

add_library(       class_functions_lib   src/class_functions.cpp)
add_dependencies(     class_functions_lib   ${catkin_EXPORTED_TARGETS})
target_link_libraries( class_functions_lib   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

add_executable(       class_node   src/class_node.cpp)
add_dependencies(     class_node   ${catkin_EXPORTED_TARGETS})
target_link_libraries( class_node class_functions_lib   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

or for

add_executable(       class_node   src/class_node.cpp  src/class_functions.cpp )
add_dependencies(     class_node   ${catkin_EXPORTED_TARGETS})
target_link_libraries( class_node class_functions_lib   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

.

The first version creates you a lib ( shared object (.so) file ) and links your exec to your lib. The second version compiles boths source files to object files (.o) and links them both to an executable file containing compiled code of all your files.

You have to change

add_executable(       class_node   src/class_node.cpp)
add_dependencies(     class_node   ${catkin_EXPORTED_TARGETS})
target_link_libraries(class_node   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

add_executable(       class_functions   src/class_functions.cpp)
add_dependencies(     class_functions   ${catkin_EXPORTED_TARGETS})
target_link_libraries(class_functions   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

either for

add_library(       class_functions_lib   src/class_functions.cpp)
add_dependencies(     class_functions_lib   ${catkin_EXPORTED_TARGETS})
target_link_libraries( class_functions_lib   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

add_executable(       class_node   src/class_node.cpp)
add_dependencies(     class_node   ${catkin_EXPORTED_TARGETS})
target_link_libraries( class_node class_functions_lib   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

or for

add_executable(       class_node   src/class_node.cpp  src/class_functions.cpp )
add_dependencies(     class_node   ${catkin_EXPORTED_TARGETS})
target_link_libraries( class_node class_functions_lib   ${catkin_LIBRARIES}  ${PCL_LIBRARIES}  ${OpenCV_LIBRARIES})

.

The first version creates you a lib ( shared object (.so) file ) and links your exec to your lib. The second version compiles boths source files to object files (.o) and links them both to an executable file containing compiled code of all your files.