ROS generate_ messages_ Solution of CPP compilation error
Learning the knowledge of C + + and python joint programming under ROS, there is an error report when compiling cpp file, the following process is recorded:
-
- in the reference → Article 1 ← for configuration, the insertion of CPP and py has been completed, and
catkin is performed_ There are errors in the make
-
- steps, and the error contents are as follows:
CMake Error at my_pkg/CMakeLists.txt:27 (add_dependencies):
The dependency target "my_pkg_generate_messages_cpp" of target "listener"
does not exist.
The cmake version is adjusted according to Article 2 ←, and no error is reported. The principle is that cmake before 3.0 will turn this error report into a warning, and it has passed the compilation, but in actual use, it is still unable to find the listener
program built from CPP. Finally, the cmakelists
is adjusted according to Article 3 ←,
– first of all, Add the following code block:
catkin_package(
INCLUDE_DIRS include
# LIBRARIES strands_gazing
CATKIN_DEPENDS std_msgs
# DEPENDS system_lib
)
After that, in Add_ Added
finally, when compiling, execute ${catkin> to dependencies
_ EXPORTED_ Targets} catkin first_ make --pkg my_ PKG (here is the PKG name)
, and then execute catkin_ Make
problem solving
Finally, the revised cmakelists
:
cmake_minimum_required(VERSION 3.0.2)
project(my_pkg)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES strands_gazing
CATKIN_DEPENDS std_msgs
# DEPENDS system_lib
)
include_directories(include/my_pkg ${catkin_INCLUDE_DIRS})
add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener my_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
Read More:
- Python Post kafka Messages Error: [Error 10] MessageSizeTooLargeError
- How to Solve Turtle_tf Error in ROS
- [Solved] ROS fatal error: NvInferRuntimeCommon. h: No such file or directory
- [Solved] cv2.error: OpenCV(4.5.1) XXX\shapedescr.cpp:315: error: (-215:Assertion failed) npoints >= 0 &&……
- Python pyqt5 ui Generate .py File Error [How to Solve]
- [Solved] Cv2.imshow Error: window.cpp:1274: error: (-2:Unspecified error) The function is not implemented.
- YOLOX Model conversion error: [TensorRT] ERROR: runtime.cpp (25) – Cuda Error in allocate: 2 (out of memory)
- [Solved] Mindspore 1.3.0 Compile Error: CMake Error at cmake/utils
- [Solved] lto1: fatal error: bytecode stream..generated with LTO version 6.2 instead of the expected 8.1 compi
- Solution for Python3.7 import gevent module error
- [Solved] awtk scons Error: unsupported pickle protocol: 4
- [Solved] Pyinstaller packaged exe error: “failed to execute script XXX”
- About the solution of ERROR: Failed building wheel for dlib
- How to Solve ModuleNotFoundError Error After pip-autoremove Installed
- [Solved] Error: [email protected]: wrong number of arguments (given 1, expected 0)
- [Solved] cv2.xfeatures2d.SIFT_create() Error: module ‘cv2.cv2’ has no attribute ‘xfeatures2d’
- FileNotFoundError: Could not find module ‘D:\Anaconda3\envs\labe\Library\bin\geos_c.dll‘ [Solved]
- How to Solve Python3.9 Install pycrypto Error
- Ctypes DLL Error: FileNotFoundError: Could not find module ‘***_dll.dll‘ (or one of its dependencies).
- [Solved] Django.core.exceptions.ImproperlyConfigured: SQLite 3.9.0 or later is required (found 3.7.17).