在 Windows 中安装 MinGW-w64(mingw-w64-builds-binaries/WinLibs/Cygwin)

下载

Github

Releases · niXman/mingw-builds-binaries

32 位使用 i686-*-dwarf-ucrt-*.7z
64 位使用 x86_64-*-seh-ucrt-*.7z
至于线程模型 也就是 posix 和 win32 我不太清楚 放个评论区别人说的:

① POSIX(与其他平台的最佳兼容性)
② WIN32 (本机 Windows 线程,但缺少 POSIX 线程 / pthread.h)
③ MCF(自 GCC 13 起,另请参阅:MCF Gthread 库)
——天神永恒

点击下载,下载速度可能会比较慢,或者可以使用 Github 镜像加速,如 ghproxy.net mirror.ghproxy.com

WinLibs

WinLibs - GCC+MinGW-w64 compiler for Windows

下右面 without LLVM/Clang/LLD/LLDB 里的,上面是 32位 ,下面是 64位,7-Zip achive 和 Zip achive 没区别就是压缩方式不一样

Cygwin

setup-x86_64.exe
安装程序建议留着,更新要用
根目录和本地软件包目录都用一个目录就行,也是最好没有中文和空格,这个目录和上面的解压目录一样
选择完整,搜索下面这几个包,把跳过改成最新版本(这里已经装完了)

一路下一步就安装完了

解压

将下载的压缩包全部解压,路径最好不要有中文和空格
(Cygwin 安装不需要)

设置环境变量

打开 设置->系统->系统信息->高级系统设置->环境变量 或直接运行 SystemPropertiesAdvanced.exe 点击环境变量

双击用户变量下的 Path

Windows 10以上:点击新建,输入 解压目录\bin
Windows 7:在 变量值 最后添加 解压目录\bin;
点击确定

测试一下,打开 cmd ,输入 gcc --version

显示版本号就说明安装成功了
编译命令:

# C
gcc <filename>.c -o <filename>.exe
# C++
g++ <filename>.cpp -o <filename>.exe

这个命令会用 gcc / g++ 编译<filename>.c/<filename>.cpp,输出文件为 <filename>.exe
编译没出错的话应该没有输出

Upd. 2024/8/21 改了改,添加了别的下载方式

从SourceForge上Dump下来的MinGW最新版5.0.X完整版,涵盖完整迁移库,值得拥有。 完整可引入header列表: \MINGW\INCLUDE │ accctrl.h │ aclapi.h │ aclui.h │ adsprop.h │ afxres.h │ amaudio.h │ amvideo.h │ assert.h │ audevcod.h │ autosprintf.h │ aviriff.h │ aygshell.h │ basetsd.h │ basetyps.h │ bdatypes.h │ cderr.h │ cguid.h │ cmnquery.h │ comcat.h │ commctrl.h │ commdlg.h │ complex.h │ conio.h │ control.h │ cpl.h │ cplext.h │ ctype.h │ custcntl.h │ d3d9.h │ d3d9caps.h │ d3d9types.h │ dbt.h │ dde.h │ ddeml.h │ devguid.h │ dhcpcsdk.h │ dir.h │ direct.h │ dirent.h │ dlfcn.h │ dlgs.h │ docobj.h │ dos.h │ dsadmin.h │ dsclient.h │ dsgetdc.h │ dshow.h │ dsquery.h │ dsrole.h │ dvdevcod.h │ dvdmedia.h │ dxerr8.h │ dxerr9.h │ edevdefs.h │ errno.h │ errorrep.h │ errors.h │ evcode.h │ excpt.h │ exdisp.h │ exdispid.h │ fcntl.h │ fenv.h │ float.h │ fltdefs.h │ gdiplus.h │ getopt.h │ gettext-po.h │ glob.h │ gmon.h │ httpext.h │ icm.h │ iconv.h │ idispids.h │ il21dec.h │ imagehlp.h │ imm.h │ initguid.h │ intshcut.h │ inttypes.h │ io.h │ ipexport.h │ iphlpapi.h │ ipifcons.h │ ipinfoid.h │ iprtrmib.h │ iptypes.h │ ipxconst.h │ ipxrtdef.h │ ipxtfflt.h │ isguids.h │ ks.h │ ksmedia.h │ largeint.h │ libcharset.h │ libgen.h │ libintl.h │ limits.h │ lm.h │ lmaccess.h │ lmalert.h │ lmapibuf.h │ lmat.h │ lmaudit.h │ lmbrowsr.h │ lmchdev.h │ lmconfig.h │ lmcons.h │ lmerr.h │ lmerrlog.h │ lmmsg.h │ lmremutl.h │ lmrepl.h │ lmserver.h │ lmshare.h │ lmsname.h │ lmstats.h │ lmsvc.h │ lmuse.h │ lmuseflg.h │ lmwksta.h │ localcharset.h │ locale.h │ ltdl.h │ lzexpand.h │ malloc.h │ mapi.h │ math.h │ mbctype.h │ mbstring.h │ mciavi.h │ mcx.h │ mem.h │ memory.h │ mgm.h │ mgmtapi.h │ mlang.h │ mmreg.h │ mmsystem.h │ mpegtype.h │ mprapi.h │ mq.h │ msacm.h │ mshtml.h │ msvcrtver.h │ mswsock.h │ nb30.h │ nddeapi.h │ nspapi.h │ ntdef.h │ ntdll.h │ ntdsapi.h │ ntdsbcli.h │ ntldap.h │ ntsecapi.h │
评论 53
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值