One of the advantages of Linux as an open source system is the efficient collection of libraries compiled from a variety of sources, creating a convenient way for the project to be used. Normally, when we develop our own open source projects, we like to use CMake to invoke various three-party libraries, such as OPENCV, PCL, G2O, etc., in the existing functions to assist their own program development, The current mainstream approach is to write CMakeLIsts.txt files in the project, using the CMake command to link the dynamic library of the three-party library to the project, which eliminates the complexity of the environment configuration problems in the IDE.
The directory structure of the project that has been written is generally as follows:
Project----------------Bin folder to hold the generated executable file
|---------------build folder for compiling, linking process-generated files
|---------------the Include folder is used to store the project source header file
|---------------src folder to hold the project's. cpp file
|---------------Lib folder to hold the. So file for the project
|---------------CMakeLIsts.txt due to cmake file
We have already understood the directory structure of the CMake project, the general execution
CD build/
CMake.
Make
You can build the project's executable file under the Bin folder. But in the Linux system debugging has encountered a problem, if there is no IDE, then you can only use the Linux system comes with the debugger debugging, the personal sense of visibility is not too good. So you're going to import the CMake project into Eclipse to debug. Specific conversion commands See blog 49205221, if you build a debug Eclipse project, when you write CMakeLIsts.txt, you should add
Set (Cmake_build_type Debug)
According to the method of the blog, if the execution
CD build/
Cmake-g "Eclipse Cdt4-unix makefiles"-D cmake_build_type=debug.
The following prompt will appear
There will be cmake Warning hints that the Eclipse project generated under the Build folder is not well supported in eclipse. It turns out that the resulting eclipse project cannot run in eclipse
So do not compile under the build folder, execute the following command:
CD project/
Cmake-g "Eclipse Cdt4-unix makefiles"-D cmake_build_type=debug.
The compilation results are as follows:
You can see that there is no cmake Warning, import into eclipse can be compiled, you can run the program, and you can debug the program.
Convert CMake projects into eclipse in Linux16.04 LTS environment to import projects that can be debugged