Win7下msys64安裝mingw工具鏈


1. 安裝msys64

安裝到指定目錄, 例如C:\msys64 

2. 命令行更新

運行msys2.exe打開命令行窗口, 執行命令

pacman -Syuu

 

3. 修改安裝源

進入msys64/etc/pacman.d/, 需要修改三個文件, 都添加在Server列表第一行

mirrorlist.mingw32
Server = http://mirrors.ustc.edu.cn/msys2/mingw/i686/

mirrorlist.mingw64
Server = http://mirrors.ustc.edu.cn/msys2/mingw/x86_64/

mirrorlist.msys
Server = http://mirrors.ustc.edu.cn/msys2/msys/$arch/

4. 命令行安裝

在msys2窗口內, 命令行執行

pacman -S --needed base-devel mingw-w64-x86_64-toolchain git mingw-w64-x86_64-cmake

稍等完成之后就擁有了mingw64 工具鏈, 會出現選擇提示, 空間足夠的話就全部安裝吧, 還可以選擇的軟件有 git  mercurial  cvs  wget  p7zip  perl  ruby  python2

 

5. 配置

將mingw64的路徑(例如 C:\msys64\mingw64\bin )添加到PATH目錄, 添加完后, 在Eclipse CDT的Perference C/C++ -> Core Build Toolchains 中Available Toolchains就能看到GCC了

Update 2019-11-12: 配置GNU99, 打開 project properties. -> C/C++Build -> Settings,  Tool Settings 標簽頁-> GCC C compiler -> Miscellaneous.  在 other flags 輸入框, 添加 -std=c99 , Apply&Close. 配合 #include <stdbool.h> 就可以使用 bool, true, false關鍵字了.

參考

https://github.com/orlp/dev-on-windows/wiki/Installing-GCC--&-MSYS2

https://stackoverflow.com/questions/4236323/how-do-you-configure-gcc-in-eclipse-to-use-c99

https://www.eclipse.org/cdt/downloads.php Eclipse CDT下載頁, 用於在Eclipse中添加安裝源.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM