Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

An example of vscode configuring the cripple + development environment

Shulou Source: shulou.com Published: 2022-06-02 15:48:38 10月03日 Update

The editor would like to share with you an example of how to configure the vscode development environment. I hope you will get something after reading this article. Let's discuss it together.

1. Install the cpptools tool

Open vscode and follow the steps shown in the figure to install

2. Download MinGW

Download address: https://sourceforge.net/projects/mingw-w64/files/

Downloaded file: after entering the website, do not click "Download Lasted Version", slide down to find the latest version of "x86_64-posix-seh".

Install MinGW: download a 7z zip file, unpack it and move it to the location you want to install. My installation location is: d:\ 2Software\ mingw64

3. Configure environment variables

Configuration object: WinGW, copy the path where you just installed WinGW

Configure environment variables: take win10 as an example and follow the steps shown in the figure

Restart VScode after configuring the environment variables.

4. Verify whether the environment variables are configured successfully.

Press win + R, enter cmd, enter after enter, enter enter, and then enter. If prompted with the following information [1], the environment variable is configured successfully. If the following information [2] is prompted, the configuration of the environment variable fails.

[1]: galleys: fatal error: no input files

[2]: 'gapproved commands' is not an internal or external command, nor is it a runnable program or batch file.

5. Configure the C++ environment with a simple .cpp file.

Create a new empty folder Code

Open VScode-- > Open folder-- > Select the folder you just created Code

Create a new test.cpp file (take the simplest HelloWorld.cpp as an example)

Enter the debugging interface to add the configuration environment, select C++ (GDB/LLDB), and then select g++.exe, after which the launch.json configuration file will be automatically generated.

Edit launch.json profile

{"version": "0.2.0", "configurations": [{"name": "g++.exe build and debug active file", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\ ${fileBasenameNoExtension} .exe", "args": [] "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, / / modify this item Let the terminal "MIMode": "gdb", "miDebuggerPath": "D:\\ 2Software\\ mingw64\\ bin\\ gdb.exe", "setupCommands": [{"description": "Enable pretty-printing for gdb", "text": "- enable-pretty-printing" "ignoreFailures": true}], "preLaunchTask": "task gaming +" / / modify this item}]}

Return to the .cpp file, press F5 to debug, the task "task gathers +" will pop up, select "configure Task", and the tasks.json file will be generated automatically.

Edit the tasks.json file

{"version": "2.0.0", "tasks": [{"type": "shell", "label": "task command +", / / modify the entry "command": "D:\\ 2Software\\ mingw64\\ bin\\ g++.exe", "args": ["- g" "${file}", "- o", "${fileDirname}\\ ${fileBasenameNoExtension} .exe"], "options": {"cwd": "D:\\ 2Software\\ mingw64\\ bin"} "problemMatcher": ["$gcc"], "group": "build"}}

[note]: the value of "preLaunchTask" in the launch.json file must be consistent with the value of "label" in the tasks.json file. The setting of the value depends on personal preference, and the default value is also OK.

6. Run

Return to the HelloWorld.cpp file, press F5 to debug, and find that it is completely OK!

After reading this article, I believe you have a certain understanding of the "example of vscode configuration cswab + development environment". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Tags: Configuration files environment variables selections folders examples development success tasks locations information steps articles automatic generation clocking such as figure prompt generation input Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno Docker MySQL Microsoft