In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge of this article, "how to configure the environment for compiling C++ in Visual Studio Code". So the editor gave you a summary of the following contents, detailed contents, clear steps, and a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to configure the environment for compilation of C++ in Visual Studio Code" article.
I. brief introduction
The C++ compilation environment used by in college has always been Visual Studio 2010. Recently, I encountered a competition problem, which requires the environment of Clover 11, and gives the basic code. The underlying code does not run successfully on Visual Studio 2010 with the following error:
after the query, because Visual Studio 2010 to 2013 these versions support only part of the Clippers 11 features, so the error, and think of Visual Studio Code and its are one, there are many people recommend, thinking that you can use it to achieve C++ environment compilation, after all, if you download a high version of Visual Studio not only big, open the speed in my broken computer will be slow.
Second, prepare tools
Visual Studio Code
This can be downloaded and installed directly from the official website.
Visual Studio Code extension
The two plug-ins can be installed directly through the search for the extension library, and the restart takes effect after installation.
Mingw compiler
Official download address: https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/
Installation files can be downloaded from the official website, or compressed packages can be downloaded directly without installation.
After the download and installation is complete, you need to configure the bin folder of mingw to the environment variable of your computer.
Then enter cmd through win+r to open the command line, and then type gcc-v to show the correct version number, which means that the configuration is successful.
III. Configuration file
There should be many ways for to configure Visual Studio Code's C++ environment, and I've used two of them here.
1. Configure Code Runner to find the extension, click the tool icon, and find the extension settings
Go to the extension settings and find Code-runner: Executor Map for editing
Find "cpp" and add-std=c++11 at the specified location
Then restart Visual Studio Code. When you want to run the C++ program, click on the start button at the top right.
Enter in the read-only box of the output by selecting the option below the code-runner: run in terminal box
2. Run and debug configuration
here we need to configure two items, one is to configure launch.json, the other is to configure tasks.json, there are templates, directly copy the template, you only need to change the mingw reference path
Launch.json
{/ / Use IntelliSense to learn about possible attributes. / / Hover to view descriptions of existing attributes. / / For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [{"name": "C++ (gdb) Launch", "preLaunchTask": "g++.exe build active file", "type": "cppdbg", / / only cppdbg "request": "launch" "program": "${fileDirname} ${fileBasenameNoExtension} .exe", / / path name of debugger "args": [], / / debug pass parameters "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb" "miDebuggerPath": "C:mingw64ingdb.exe", "setupCommands": [{"description": "Enable pretty-printing for gdb", "text": "- enable-pretty-printing", "ignoreFailures": true}]}}
Tasks.json
{"version": "2.0.0", "tasks": [{"type": "shell", "label": "g++.exe build active file", "command": "C:mingw64ing++.exe" "args": ["- g", "${file}", "- o", "${fileDirname} ${fileBasenameNoExtension} .exe"] "options": {"cwd": "C:mingw64in"}, "problemMatcher": ["$gcc"] "group": {"kind": "build", "isDefault": true}]}
Once configured, you can debug and run through the run on the top navigation bar
The above is about "how to configure C++ compilation environment in Visual Studio Code" this article, I believe we all have a certain understanding, I hope the editor to share the content to help you, if you want to know more related knowledge, please follow the industry information channel.
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.