In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, Xiaobian will bring you a simple use of cmake in ROS. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.
Compile operations in ROS Note that you use your own package management tools
catkin_make
to compile. The build configuration file where cmake needs to be configured. Here's a discussion of the simple cmake basics ROS needs.
What is cmake?
CMake is an open source cross-platform automated build system that uses configuration files to control the build process in a similar way to Unix Make, except that CMake's configuration file is named CmakeLists.txt. Cmake does not directly build the final software, but instead generates standard build files (such as Unix Makefiles or Windows Visual C++ projects/workspaces) that are then used in the usual build mode. This allows developers familiar with an IDE to build their software in a standard way, and this ability to use native build systems across platforms is what differentiates CMake from other similar systems such as SCons. CMake compiles source code, makes libraries, generates wrappers, and builds executables in any order. CMake supports in-place construction (binary files in the same directory tree as source code) and out-of-place construction (binary files in different directories), making it easy to construct multiple binary files from the same source tree. CMake also supports the construction of static and dynamic libraries. The name "C Make" stands for "cross platform make." Although the name contains the word "make," CMake is separate and more advanced than the common "make" system on Unix.
1. A simple example, using cmake to compile a simple c file (Ubuntu 14.04) should be the same for other Linux.
New t.c file
#include int main(){ printf("hello cmake\n");}
Create CMakeLists.txt under the same folder
cmake_minimum_required(VERSION 2.8)project(test)add_executable(test t.c)
Run in current folder
$ cmake .$ make
You can get the executable file 'test', which Linux can run to get results.
2. Compile opencv with cmake
This assumes that you already have the OpenCV library installed. It runs on the Ubuntu platform.
Similar to example 1, create a new project folder in the current folder, which contains src folder, build folder, and file CMakeLists.txt
catalog results
.|---- build|----CMakeLists.txt|----src |---test.cpp
Write the following in CMakeLists.txt
cmake_policy(SET CMP0003 NEW)cmake_minimum_required(VERSION 2.8)project(test)find_package(OpenCV REQUIRED)add_executable(test ./ src/test.cpp)target_link_libraries(test ${OpenCV_LIBS})
Write the following in `test.cpp`
#include #include #include #include using namespace cv; using namespace std; int main(int argc, char* argv[]) { Mat image; if (argc != 2 || ! image.data) { printf("No image data\n"); return -1; } image = imread(argv[1], 1); namedWindow("Display Image"); imshow("Display Image", image); waitKey(0); return 0; }
The purpose of this file is to read in the image and display it in a pop-up window, go to the build folder and run cmake , make
$ cd build$ cmake ../$ make$ ./ test ../ path/to/your/test**.png
You will see the results of the run.
The above is how to carry out the simple use of cmake in ROS shared by everyone. If there is a similar doubt, please refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.