今天安装下载MinGW-W64-install.exe安装MinGW试了好几次都失败了
因此决定用离线安装包进行安装
1.下载
下载地址 https://sourceforge.net/projects/mingw-w64/files/?source=navbar
下载后解压到指定目录,如D:\mingw64
2.设置环境变量
set MINGW_HOME=D:\mingw64
set path =%MINGW_HOME%\bin\
3.测试
(1)新建main.c
#include <stdio.h> int main() { printf("hello, world! I'm C. "); return 0; }
gcc main.c –o hello_c
hello_c
输出
hello, world! I'm C.
(2)新建main.cpp
#include <iostream> int main(void) { //cout<<"hello world"<<endl; std::cout<<"hello world
!I'm C++.
"; return 0; }
g++ main.cpp –o hello_c++
hello_c++
输出
hello world !I'm C++.