如何将mingw-w64和MSYS2与任何IDE(例如eclipse或代码块)一起使用? [英] How can use mingw-w64 and MSYS2 with any IDE like eclipse or codeblocks?
问题描述
-
我使用在此处安装> .
我下载 i686-5.3.0-release-posix-dwarf-rt_v4-rev0 来自
I download i686-5.3.0-release-posix-dwarf-rt_v4-rev0 from here.
设置 msys2-i686-20160205.exe 后,在中解压缩 i686-5.3.0-release-posix-dwarf-rt_v4-rev0 C:\ msys32 .
after setup msys2-i686-20160205.exe, extract i686-5.3.0-release-posix-dwarf-rt_v4-rev0 in C:\msys32.
最后我从开始菜单运行 MinGW-w64 Win32 Shell 并分别运行以下命令:
finally i run MinGW-w64 Win32 Shell from start menu and run these commands respectively:
-
pacman -Sy pacman
pacman -Sy pacman
pacman -Syu
pacman -Syu
pacman -Su
pacman -Su
在PATH中添加 C:\ msys32 \ mingw32 \ bin .
我的问题:
- 可以在任何IDE中使用mingw-w64,这是真的吗?
- MinGW-w64 Win32 Shell 和 MSYS2 Shell 有什么区别?
- for use mingw-w64 with any IDE, is it true I do?
- what difference between MinGW-w64 Win32 Shell and MSYS2 Shell?
谢谢.
推荐答案
以前的msys2&这里的arch linux用户,目前在大学就读,该课程使用代码块作为程序是否工作的标准度量标准,我想可以为您提供帮助.
Former msys2 & arch linux user here, currently enrolled in college where the class uses codeblocks as the standard metric for whether a program works or not, and I think I can help you here.
基本要点是您希望正常安装msys2和代码块,然后使用代码块设置将编译器设置为使用msys2的mingw-w64编译器.感到困惑了吗?总体来说很简单.
The basic gist is you'd want to install msys2 normally, as well as codeblocks, then use the codeblocks settings to set your compiler to use msys2's mingw-w64 compiler. Confused yet? Its pretty simple overall.
- 安装代码块.使用已安装mingw的安装程序,稍后我们将从默认工具链中复制一些内容.
- 安装msys2(默认安装位置很好,对于64位,使用
C:\ msys64
,对于32位,我认为C:\ msys32
;我们假设使用64位本指南的其余部分).请注意无论您在何处安装它,我们稍后都将需要它. - 打开msys2 msys提示符
- 更新msys2(两部分过程,因为Windows不能轻易地交换使用中的文件)
$ pacman -Syu
;它将更新可用软件包的一小部分,并要求您关闭窗口. - 完成msys2更新
$ pacman -Syu
;这次的名单会更大. - 安装
base-devel
软件包组$ pacman -Syu base-devel
;它将提示您该组中的软件包列表.您想跳过pacman本身,否则它将具有相同的两部分更新内容.上次我检查此内容时,pacman在列表中排名第39,因此您将1-38,40-56
输入要安装的内容(根据任何$ currentdate
为您提供服务,但不一定总是39). - 安装mingw-w64工具链
pacman -Syu mingw-w64-x86_64-toolchain
,它会再次提示您选择软件包,您希望它们全部打包,因此只需按Enter键即可.如果要使用32位工具链,请使用pacman -Syu mingw-w64-i686-toolchain
. - 打开代码块.如果这是您的第一次运行,它将询问您有关文件关联和首选项等的信息.随意设置.
- 在菜单栏中,单击设置"->编译器".它应默认为
GNU GCC编译器
.在该设置下,应该有一个按钮来复制它.给新的编译器配置文件起一个描述性的名称(我使用了MSYS2 mingw-w64-x86_64 G ++
.它将提示您更新工具链可执行文件. - 在编译器屏幕上,有一个名为
工具链可执行文件
的选项卡,单击它.将Compiler的安装目录
设置为将msys2安装到的任何位置,以+ +对于64位工具链为mingw64或对于32位工具链为mingw32.假定默认安装位置和64位工具链,则应为C:\ msys64 \ mingw64
. - 在此之下,更改
Program Files
下所有选项的名称,以删除mingw32-
前缀,但Make program
除外保留mingw32-make.exe
.其他所有内容都应使用统一名称(gcc.exe
,g ++.exe
等). - 可选:将此新编译器设置为默认编译器.您可以从相同的
Settings-> Compiler
窗口执行此操作.
- Install codeblocks. Use the installer with mingw already installed, we'll be copying some stuff from the default toolchain later.
- Install msys2 (default install location is fine,
C:\msys64
for 64 bit and I thinkC:\msys32
for 32 bit; we'll assume 64 bit for the rest of this guide). Take note of wherever you do install it, we'll need it later. - open the msys2 msys prompt
- update msys2 (two part process because windows can't easily swap a file in use out)
$ pacman -Syu
; it will update a smallish subset of available packages and ask you to close the window. - finish the msys2 update
$ pacman -Syu
; this time the list will be much larger. - install the
base-devel
package group$ pacman -Syu base-devel
; it will prompt you with a list of packages in the group. You want to skip pacman itself, otherwise it will have the same two-part update thing. Last time I checked this, pacman was number 39 on the list, so you'd put in1-38,40-56
for what to install (adjust for whatever$currentdate
offers you, it may not always be 39). - install a mingw-w64 toolchain
pacman -Syu mingw-w64-x86_64-toolchain
, it will again prompt you with a choice of packages, you want them all so just hit enter. If you want the 32-bit toolchain you'd usepacman -Syu mingw-w64-i686-toolchain
. - Open codeblocks. If this is your first run, it will ask you about file associations and preferences and such. Set those however you like.
- In the menu bar, click Settings->Compiler. It should be defaulted to the
GNU GCC Compiler
. Under that setting there should be a button to copy it. Give the new compiler profile a descriptive name (I went withMSYS2 mingw-w64-x86_64 G++
. It will prompt you to update the toolchain executables. - On the compiler screen, there is a tab named
Toolchain executables
, click it. Set theCompiler's installation directory
to wherever you installed msys2 to + either mingw64 for a 64-bit toolchain or mingw32 for a 32-bit toolchain. Assuming default install location and a 64-bit toolchain, this should beC:\msys64\mingw64
. - Below this, change the names of all the options under
Program Files
to remove themingw32-
prefix, except forMake program
which must remainmingw32-make.exe
. Everything else should have flat names (gcc.exe
,g++.exe
, etc). - Optional: set this new compiler as the default. You can do this from the same
Settings->Compiler
window.
我创建了一个 youtube 视频,该视频显示了整个过程,因为我已经尚未在互联网上的任何地方看到此文件.
I've created a youtube video showing the whole process, since I've not yet seen this documented anywhere on the internet.
这篇关于如何将mingw-w64和MSYS2与任何IDE(例如eclipse或代码块)一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!