Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The method of vscode configuring the environment of cripple +

Shulou Source: shulou.com Published: 2022-06-02 16:06:05 10月04日 Update

This article will explain in detail the method of configuring the vscode environment with cswab +. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

First, install cpptools tools

Open vscode and follow these steps to install

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

Third, configure environment variables

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

Configure environment variables: take win10 as an example, after reaching step 6, press OK to open the previous window, otherwise it will fail.

[note]: win7 needs to add a path, do not overwrite it.

It is best to restart VScode after configuring the environment variables.

Verify that 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.

4. 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)

# include # include int main () {printf ("Hello World\ n"); system ("pause"); return 0;}

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, will pop up can not find the task "task gathers +", select "configure task", will automatically generate tasks.json file.

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.

V. Operation

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

This is the end of this article on "how to configure the environment of vscode Cramp +". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Configuration files environment variables selections folders articles methods success tasks locations information more automatic generation paths caching prompts generation input good Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Xiaomi Apple Shulou Information macOS