In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 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 vscode configuration, compilation and running c program environment, which is very detailed and has certain reference value. Friends who are interested must finish reading it.
Background:
1. VS Code is just a code editor. Compiling and running these tasks requires other programs to complete.
2. The choice of C _ compiler, GCC/G++ (MinFGW-w64)
3. MinGW and MinGW-w64 are two different projects. MinGW itself has not been updated for a long time, so it is not recommended. For convenience, the MinGW in this article actually refers to MinGW-w64.
4. The use of command line and the addition of system variables.
Install vs code
Plug-in installation
1. Necessary plug-ins
Ms-vscode.cpptools (official product of Microsoft): the most fully functional plug-in, and it is the official plug-in of Microsoft, you can download it at ease.
Code Runner (formulahendry.code-runner): quickly compile and run a single file, which is convenient.
2. Recommend plug-ins
Bracket Pair Colorizer: rainbow brackets, matching parentheses will be marked with the same color.
Material Icon Theme: icon package plug-in, "gaudy", recommended.
One Dark Pro: theme plug-in, recommended Chinese Language Pack: Chinese language pack.
Configure the environment:
One-click configuration:
Win7/10 is valid: if you don't want to toss around, download the one-click configuration package. After decompression, open vscode_onesrc/, and find start.bat right-> run as administrator.
The installation is successful and is shown as follows:
Manual configuration:
Configure the compiler:
You need to be able to compile Candlespace + on the command line before you can run it with VS Code.
Here we need to use GCC to compile.
Download address: https://sourceforge.net/projects/mingw-w64/
MinGW-W64 GCC-8.1.0
X86_64-win32-seh
I686-win32-dwarf
64-bit computer chooses x8664Jing 32-bit choice i686.
After the download and decompression is complete, add the system variable current path\ mingw64\ bin to the path. After setting the variable, restart the computer. Enter gcc or Gmail + on the command line
If the following interface is displayed:
The configuration is successful, proceed to the next step.
Configure Json:
The following configuration files need to be placed in the .vscode folder (note that there is a point), if the working directory is workSpace. You need to put .vscode in the workSpace directory.
The following C:\ Users\ 15591\ MyFile\ Develop\ mingw64\ include (a total of four), you need to change to your own gcc compiler installation path, if your path is C:mingw64\ you can change it to C:mingw64include
C_cpp_properties.json
{"configurations": [{"name": "Win32", "defines": ["_ DEBUG", "UNICODE", "_ UNICODE"] "includePath": ["${workspaceFolder}", "C:\\ Users\\ 15591\ MyFile\\ Develop\\ mingw64\\ include"], "browse": {"path": ["${workspaceFolder}" "C:\\ Users\\ 15591\ MyFile\\ mingw64\\ include"], "limitSymbolsToIncludedHeaders": true, "databaseFilename": ""}, "windowsSdkVersion": "10.0.17134.0" "compilerPath": "C:\\ Users\\ 15591\ MyFile\\ Develop\\ mingw64\\ bin\\ gcc.exe", "cStandard": "c11", "cppStandard": "centering 17"}], "version": 4}
Launch.json
{"version": "0.2.0", "configurations": [{"name": "(gdb) Launch", / / configuration name Display "type": "cppdbg", "request": "launch", "program": "${fileDirname} / ${fileBasenameNoExtension} .exe" in the startup configuration drop-down menu, / / the path "args" of the program to be debugged: [] / / parameters "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "internalConsoleOptions": "neverOpen", / / if it is not set to neverOpen When debugging, you will skip to the "Debug console" tab. You don't need to enter commands to gdb manually, do you? "MIMode": "gdb", "miDebuggerPath": "C:\\ Users\\ 15591\ MyFile\\ Develop\\ mingw64\\ bin\\ gdb.exe", "setupCommands": [{"description": "Enable pretty-printing for gdb" "text": "- enable-pretty-printing", "ignoreFailures": true}], "preLaunchTask": "CppCompile" / / tasks performed before the debugging session starts It is usually a compiler. Corresponds to the label of tasks.json}]}
Tasks.json
{"version": "2.0.0", "tasks": [{"label": "CppCompile", / / task name, corresponding to the preLaunchTask of launch.json "command": "Gmail +", / / the compiler to be used. We mainly debug cpp files. You can also change it to other "args": ["${file}", "- o", / / specify the output file name. If this parameter is not added, a.exe will be output by default. Default a.out "${fileDirname} / ${fileBasenameNoExtension} .exe", "- g", / / generate information related to debugging and debugging "- Wall" under Linux / / enable additional warning "- static-libgcc", / / static link "- std=c++17" / / the latest standard of C language is c11 Or modify it according to your needs], / / compile command parameter "type": "shell", / / can be shell or process, the former is equivalent to opening shell first and then entering the command The latter is to directly run the command "group": {"kind": "build", "isDefault": true / / set to false to configure multiple compilation instructions for one tasks.json, and you need to modify this file yourself. I won't mention much here, "presentation": {"echo": false, "reveal": "always", / / the strategy for displaying compilation information in the "terminal" can be always,silent,never. See the VSC document "focus": false, / / set to true to focus on the terminal when task is executed, but for compiling c and C++ Set to true meaningless "panel": "shared" / / compilation information of different files share a terminal panel}, "problemMatcher": "$gcc"}]}
Settings.json
{"workbench.colorTheme": "One Dark Pro", / / theme One Dark Pro, if you do not need to delete this line "git.enabled": false,// closes git "git.ignoreMissingGitWarning": true,// ignores git missing warning "terminal.integrated.rendererType": "dom", "breadcrumbs.enabled": true, "workbench.iconTheme": "material-icon-theme", / / icon theme If you do not need to delete the line "files.defaultLanguage": "cpp", / / ctrl+N the default language "editor.formatOnType": true, / / when you create a new file, format it when you enter it, with fewer trigger characters by default. Semicolons can trigger "editor.snippetSuggestions": "top", / / snippets code priority display completion "code-runner.runInTerminal": true, / / set to false will be output in the "output" panel, cannot be entered It is recommended to set true "code-runner.executorMap": {"c": "cd $dir & & gcc $fileName-o $fileNameWithoutExt.exe-Wall-g-Og-static-libgcc-std=c11 & & $dir$fileNameWithoutExt", "cpp": "cd $dir & & cpp + $fileName-o $fileNameWithoutExt.exe-g-Og-static-libgcc-std=c++17 & & $dir$fileNameWithoutExt"}, "code-runner.saveFileBeforeRun": true, / / Save "code-runner.preserveFocus" before run code: false / / if false After run code, the cursor will focus on the terminal. If you need to enter data frequently, you can set it to false "code-runner.clearPreviousOutput": true, / / clear the terminal message "code-runner.ignoreSelection": true,} HelloWorld belonging to code runner before each run code:
File- > open folder- > vscode_onesrc
Find and open our folder vscode_onesrc, open HelloWorld.c and click on the triangle in the upper right corner to compile and run!
Hello World!
These are all the contents of this article entitled "how to configure vscode to compile and run the c program environment". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to 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.