Successfully install mingw-w64 offline on Win10 && configure VScode C/C++

mingw-w64

download

Download address and send SourceForge-mingw-w64
Insert picture description here

If you are win10 64-bit like me, it is correct to choose x86_64-win32-seh, I don't know how to surf the Internet scientifically. . This download speed is not as good as Baidu's network disk. . Gootou save your life, some netizens gave the resources of Baidu Netdisk, refer to this pretty boy's blog- Baidu
Netdisk, why not choose the online installer, because the download is slow and will disconnect consciously. . . Great Wall Firewall

32-bit win friends choose i686, linux ones choose posix
Insert picture description here

Environment variable

It’s best not to include spaces and Chinese in the path of mingw-w64 . If you don’t, you will cry. I use ProFiles without spaces to store software that cannot include spaces.
Insert picture description here

Insert picture description here
Then open the menu bar, search for "environment variables", you can directly open the edit system environment variable form, edit Path, browse the bin folder under the path where you just pasted mingw-w64, and then always confirm
Insert picture description here

Win+R, enter cmd and gcc -vpress Enter, run , the following result appears, indicating that mingw-w64succeed is installed
Insert picture description here

VS code

C

Download and install vsc skip, choose a folder as the default folder for C/C++ development, here I create a new C folder, create a new hello.c

#include<stdio.h>
void main()
{
    
    
    printf("hello");
}

Search for C in the plug-in and install
Insert picture description here
it. After the installation is complete, press the shortcut key Ctrl+Shift+P to call up the command panel, enter C/C++, and select "Edit Configurations (UI)" to enter the configuration.

  • Configuration name: win32
  • Compiler path: D:\ProgramFiles\mingw64\bin\gcc.exe (differs from person to person)
  • IntelliSense mode: After gccx64 is
    finished, a file will be automatically produced there, regardless of it;
    then after opening hello.c, press the shortcut key Ctrl+Shift+P to call up the command panel, enter tasks, and select "Tasks: Configure Default Build Task"; Then select "C/C++: gcc.exe build active file", a task.json will be generated at this time, return to hello.c, press F5 to run and you will be able to produce lanch.json, click OK to bring it into production , And then press F5 to run the code
    Insert picture description here

C++

Here is relatively simple, create a new folder, a new file hello.cpp

#include <iostream>
int main()
{
    
    
    std::cout<<"hello C++";
    return 0;
}

This time I press F5 to search for g++, but the gcc selected above is not dead. I pressed vs code twice to produce both lanch and task. The result can be run the third time.
Insert picture description here

References

Guess you like

Origin blog.csdn.net/weixin_43031092/article/details/109066325