In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to build the VS Code C++ environment". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to build the VS Code C++ environment" can help you solve the problem.
1. Build C _ blank +
Before setting up the environment, we must install VS Code. The download address of the software is https://code.visualstudio.com/?wt.mc_id=DX_841432. After entering the official VS Code page, click "Downlaod for windown" to download. We do not need to explain the VS Code installation process here, you can search the installation process in Baidu. Next, let's take several steps to explain how VS Code sets up the Cramp Candle + environment and runs the C code, as shown below:
Step 1: press Ctrl+Shift+P to pop up the search box, and select the installation of Cmax Candle +, as shown in the following figure:
Step 2: install MinGW: you know, the GCC compiler provided on the GCC official website cannot be installed directly on the Windows platform. If we want to use the GCC compiler on the Windows platform, we can install the migrated version of GCC. Download the software from https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/. Click "mingw-get-setup.exe" to download it, as shown in the following figure:
As for the MiniGW installation process, you can refer to this article http://c.biancheng.net/view/8077.html.
Step 3: in the desktop C folder, then click File in VS Code to open the folder C folder, as shown in the following figure:
Step 4: click the first icon on the right in the image above to add a file and name it test.cpp, as shown in the following figure:
Step 5: click .vscode in the figure above, and then create a new c_cpp_properties.json in this directory, as shown below:
Step 6: modify the c_cpp_properies.json, launch.json, and tasks.json files in the figure above, as shown below:
(1) modify c_cpp_properies.json file
{"configurations": [{"name": "Win32", "includePath": ["${workspaceFolder} / * *"], "defines": ["_ DEBUG", "UNICODE", "_ UNICODE"] "compilerPath": "D:/Soft_APP/MinGW/bin/g++.exe", "cStandard": "c11", "cppStandard": "centering 17", "intelliSenseMode": "gcc-x64"}], "version": 4}
Note: the above red string must be related to the MinGW installation path.
(2) modify launch.json file
{"version": "0.2.0", "configurations": [{"name": "(gdb) Launch", / * the task performed before debugging is the label field * / "preLaunchTask" in the previously configured tasks.json: "type: g++.exe build active file", "type": "cppdbg", / / configuration type Only types can be configured for cppdbg*//* requests Can be launch (startup) or attach (additional) * / "request": "launch", / * path name of debugger * / "program": "${fileDirname}\\ ${fileBasenameNoExtension} .exe", "args": [], / * debug pass parameters * / "stopAtEntry": false, "cwd": "${workspaceFolder}" "environment": [], / * true displays an external console window False displays built-in terminal * / "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "D:\\ Soft_APP\\ MinGW\\ bin\\ gdb.exe", "setupCommands": [{"description": "Enable pretty-printing for gdb" "text": "- enable-pretty-printing", "ignoreFailures": true}]}}
Note: the above red string must be related to the MinGW installation path.
(3) modify tasks.json file
{"version": "2.0.0", "tasks": [{"type": "shell", / * the name of the task is what you just saw when you selected it in the command panel. You can set * / "label": "g++.exe build active file", "command": "D:\\ Soft_APP\\ MinGW\\ bin\\ g++.exe", "args": [/ * compile-time parameter * / "- g", / * add gdb debugging options * / "${file}" "- o", / * specify the name of the generated executable file * / "${fileDirname}\\ ${fileBasenameNoExtension} .exe"], "options": {"cwd": "${workspaceFolder}"}, "problemMatcher": ["$gcc"] "group": {"kind": "test", "isDefault": true/* indicates that the shortcut key Ctrl+Shift+B can run the task * /}}]}
Note: the above red string must be related to the MinGW installation path.
Step 7: open the test.cpp file and write the C language code, as shown in the following figure:
Step 8: press F5 or run to start debugging, as shown in the following figure:
The image above is automatically popped up by the system at run time.
two。 Matters needing attention
(1) if there is no gdb.exe in the bin/ folder of the software path when installing MinGW, you need to install it yourself. Press win+r to enter CMD, and then cd D:\ Soft_APP\ MinGW\ bin to switch the path, which is the MiniGW installation path of the editor. Please press the "mingw-get install gdb" command according to your own installation path, as shown in the following figure:
(2) if the operation has been terminated and the exit code is 1 "error occurs, open the CMD command line to change to the project path and enter the" execution file name.exe-o execution file name .exe, as shown below: "
After the operation in the figure above, the system will pop up a prompt for what software to use to open it. We choose VS Code and then run VS Code without this error.
(3) make sure that MinGW is installed successfully. If you enter the "gcc-v" command on the CMD command line and the system prompts you that it is not a system command or other error, you must add "MinGW/bin" to the environment variable, as shown in the following figure:
This is the end of the introduction on "how to build the VS Code C++ environment". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.