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--
Today, the editor would like to share with you how to configure the C++ compilation environment in Visual Studio Code related knowledge points, the content is detailed, the logic is clear, I believe most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.
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
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:\ mingw64\\ bin\\ gdb.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:\\ mingw64\\ bin\\ g++.exe" "args": ["- g", "${file}", "- o", "${fileDirname}\\ ${fileBasenameNoExtension} .exe"] "options": {"cwd": "C:\\ mingw64\\ bin"}, "problemMatcher": ["$gcc"] "group": {"kind": "build", "isDefault": true}}]} above are all the contents of the article "how to configure the C++ compilation environment in Visual Studio Code" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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.