Summary of common errors and warnings of CMAKE in ROS

 This article mainly summarizes the warnings and errors I often encounter when compiling ROS files, and will be updated from time to time.

  1. -Wreorder warning

This kind of warning is mainly when the definition or declaration is inconsistent with the previously defined order, you only need to adjust the order to be consistent.

2. passing 'const xxx ' as 'this' argument discards qualifiers [-fpermissive] 错误

Mainly due to the wrong use of the const tag, especially for variables that will be modified, use const so that it will not be modified

3. error: no matching function for call to ‘ratslam::LocalViewMatch::on_image(const value_type*, bool, const _width_type&, const _height_type&, cv_bridge::CvImageConstPtr&, OrbVocabulary&, OrbLoopDetector&, DLoopDetector::TemplatedLoopDetector<cv::Mat, DBoW2::FORB>::Parameters&)’
 " ? false : true), image->width, image->height, cv_ptr, voc, detector, params);

The main reason for this is that no corresponding matching function was found. It may be because the head has been modified and the tail has not been considered. It is necessary to go back to find the definition and make some modifications.

4. In file included from /home/edward/catkin_ws/src/ratslam_ros/src/ratslam/local_view_match.cpp:29:0:
/home/edward/catkin_ws/src/ratslam_ros/src/ratslam/local_view_match.h:44:10: fatal error: DUtils.h: 没有那个文件或目录
 #include "DUtils.h"
          ^~~~~~~~~~
compilation terminated.
ratslam_ros/CMakeFiles/ratslam.dir/build.make:110: recipe for target 'ratslam_ros/CMakeFiles/ratslam.dir/src/ratslam/local_view_match.cpp.o' failed
make[2]: *** [ratslam_ros/CMakeFiles/ratslam.dir/src/ratslam/local_view_match.cpp.o] Error 1
CMakeFiles/Makefile2:2877: recipe for target 'ratslam_ros/CMakeFiles/ratslam.dir/all' failed
make[1]: *** [ratslam_ros/CMakeFiles/ratslam.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j1 -l1" failed

 This kind of problem is very strange, because when I make in the build, there is no error about the include header file, but it appears in catkin, and the corresponding header can also be found in the folder of my build document. So I couldn't figure it out. I searched for the difference between make and catkinmake all day long. At the same time, I asked some big guys in the WeChat group to find answers. The make file called is actually the same cmakelists, but one is under the common gnuC, and the other is under the ROS environment, the meaning of the big guy is almost this). But there is still no idea to solve my problem, so some big guys in the group suggested directly using the absolute path method to modify in the program, but in my opinion, this is the most stupid way, and it is really impossible to do it again. So, I persisted for another morning, and still had no clue. After trying several other solutions, I made up my mind to modify the original cmakelists (mainly the original one was too messy, the two intersected together, it was ugly understand, easy to be confused), I rewrote the cmakelists according to another format, and finally found the bugs in it under all kinds of difficulties and dangers.

The main reason is the lack of this sentence target_include_directories(ratslam_em PUBLIC ${DLib_INCLUDE_DIRS} ${DBoW2_INCLUDE_DIRS})

 The final result is 100% compiled and passed.

The process of solving this bug was not smooth, but I suddenly remembered a sentence that Mr. Weng Kai said in the C language programming class: You must have a very strong mental state to learn computers. What, all things in computers are What people have made, I can think of what other people can think of. There is no black magic in the computer. Everything is just that I don’t know now. One day I will figure out the details of it. !

come on! COME ON!

 

Guess you like

Origin blog.csdn.net/loveSIYU/article/details/115203751