ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
To answer your last question, you do not necessarily need to compile your standalone (in the sense of ROS independent) c code within catkin. It is pretty straight forward to compile your c code as a shared or static library, and then link your ROS node to it using the standard CMake syntax (by adding your c library to target_link_libraries(...) for example).
To address your linker errors. You are not missing header files, you are improperly specify the libraries to link to and the library search paths. Remember that "-L" specifies the search path, and the "-l" specifies the library name (preferably without path and without ending). For object files ".o" you do not need the "-l" flag prefix. you are missing lots of opencv libraries in command, you can try adding "-lopencv_core" and "-lcv_bridge -limage_transport" to take care of the missing OpenCV and OpenCV binding symbols.
But I highly recommend you use the cakin for building and integrating your ROS code, and not to build things by hand.
2 | No.2 Revision |
To answer your last question, you do not necessarily need to compile your standalone (in the sense of ROS independent) c code within catkin. It is pretty straight forward to compile your c code as a shared or static library, and then link your ROS node to it using the standard CMake syntax (by adding your c library to target_link_libraries(...) for example).
To address your linker errors. You are not missing header files, you are improperly specify the libraries to link to and the library search paths. Remember that "-L" specifies the search path, and the "-l" specifies the library name (preferably without path and without ending). For object files ".o" you do not need the "-l" flag prefix. you are missing lots of opencv libraries in command, you can try adding "-lopencv_core" and "-lcv_bridge -limage_transport" to take care of the missing OpenCV and OpenCV binding symbols.
But I highly recommend you use the cakin for building and integrating your ROS code, and not to build things by hand.
EDIT: Responding to your further comments, you are using the CMake commands incorrectly. To create your library and link to it in CMake you should use:
add_library(upd_to_ros SHARED src/upd_to_ros3.cpp) #add the source files for your "external" library code here
add_executable(imageconv_node src/ros_cpp.cpp )
target_link_libraries(imageconv_node
upd_to_ros
${catkin_LIBRARIES}
)
Note that your ROS node imageconv_node declared in your CMakeLists.txt will need a typical main function, and it is bad practice to hard code full paths in a CMakeLists.txt.