Convert CMake projects into eclipse in Linux16.04 LTS environment to import projects that can be debugged

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.