Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of vscode compiling and running the program cinning +

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of compiling and running the vscode program, which has certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

Install the Microsoft Cdebar Clipper + plug-in

Search VS Code's extension icon for clocked cards, install the Cmax Candle + plug-in and reload VS Code

After restarting VS Code, open a folder with cAccord + source code, and VS Code will create a subfolder called .vscode to hold the configuration files.

Install MinGW

Go to the official website to download the installer, and after installation, select the tools you need to install:

Apply the changes after selection:

Then modify the environment variable of the system to add the executable directory to the Path:

Intelligent hint

To achieve code completion, you need to create a c_cpp_properties.json file. Create a new hello.c and enter:

# include int main (void) {printf ("hello"); getchar (); return 0;}

VS Code will prompt that the header file cannot be found, click on the small light bulb in the error, and edit the include path.

Modify the path settings under Win32 in c_cpp_properties.json

"browse": {"path": ["${workspaceRoot}", "C:\\ DevProgram\\ MinGW\\ lib\\ gcc\\ mingw32\\ 6.3.0\ include\\ C++"], "limitSymbolsToIncludedHeaders": true, "databaseFilename": ""}

Go back to the editor, click the small light bulb, and add the directory where the header file is located to the include path

Construction program

The builder needs to create a tasks.json file. Click Task-> configure Task:

Select Others in the pop-up options, and then modify tasks.json

{"version": "2.0.0", "tasks": [{"taskName": "build hello", "type": "shell", "command": "command +", "args": ["- g", "hello.c"] "group": {"kind": "build", "isDefault": true}]} debug the code

To debug the code, you need to create a launch.json file. Click the gear icon in the debug bar.

Modify launch.json

{"version": "0.2.0", "configurations": [{"name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder} / a.exe", "args": [] "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "C:\ DevProgram\\ MinGW\\ bin\\ gdb.exe" "setupCommands": [{"description": "Enable pretty-printing for gdb", "text": "- enable-pretty-printing", "ignoreFailures": true}] "preLaunchTask": "build hello"}]} debug and run

Go back to the editor, set a breakpoint, and press F5 to start debugging

Thank you for reading this article carefully. I hope it is helpful for everyone to share the method of vscode compiling and running cripple + program. At the same time, I also hope that you can support it, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report