1、 Environmental description
1) Suggestions for GCC / G + + cmake installation
The GCC / G + + kernel comes with it. If you need a new self installation,
The same is true for cmake. If you need a new version, install it yourself.
2) Vscode install plug-in
Necessary plug-ins C / C + + 0.28.1 cmake 0.0.17 cmake tools 1.4
2、 Create project experiment
1) Open project folder
Step 1: open vscode, click the file in the upper left corner and select open folder from the drop-down menu! Note that it’s the open folder, not the workspace, or anything else!!
Step 2: randomly select an empty folder and click OK. After selection, the project directory will appear, as shown in the figure below
2) Configuration environment
Step 1: configure the cmake environment, press the shortcut key Ctrl + Shift + P or F1, and enter quick start to select cmake: quick start in the pop-up command window
If there are no gcc compiler options listed, select scan a kit for test. If no kit is found after searching, enter cmake: edit user local cmake kits in the command window, Then configure cmake tools in the format shown in the figure according to the environment configuration of GCC you installed- kets.json 。
Step 1 continued: cmake tools- kets.json After the file is saved, re-enter cmake: quick start in the command window, and the compiler option will appear. Select the corresponding compiler. If there is still no kit, select the [unspecified] item, and then enter a project name,
As shown in the figure below, the first library is to create a library, and the second executable is to create an executable file. Here, I select the second executable file, and then it will be created main.cpp Documents and CMakeList.txt (it’s up to the compiler to tell the compiler how to compile)
Step 2: modify CMakeList.txt file
CMakeList.txt The file is designed to run the program simply and add additional commands as needed
Good configuration CMakeList.txt After that, click the cmake button at the bottom of the file, and then click
Button (located at the top of the directory, below the edit menu) cofigure all project (actually to execute the cmake command), and then click the
Button build all projects (actually make)
After that, the executable file will be generated in the build folder under the project directory（ CMakeList.txt Document definition)
Open the command line in the executable file directory to execute the compiled program
At this point, CentOS 7 uses vscode + cmake to configure a simple C + + project.
This article on CentOS 7 vscode cmake compiler c + + project tutorial detailed explanation of the article introduced here, more related CentOS 7 vscode cmake compiler c + + content, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!