如何安装MinGW-w64和MSYS2? [英] How to install MinGW-w64 and MSYS2?

查看:1537
本文介绍了如何安装MinGW-w64和MSYS2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图构建一些开源库。我需要包管理系统来轻松下载依赖项。首先,我使用 MinGW + MSYS 。但包括的包是有限的。有人告诉我使用 MinGW-w64 + MSYS2



我下载了 mingw- w64-install 从(根据要使用的Windows版本,选择32或64位,而不是要构建的可执行文件类型,这两个版本都可以构建32位和64位二进制文​​件。)


  • 安装完成后,单击新创建的MSYS2 Shell code> MSYS2 64位或 MSYS2 32位。根据wiki更新MSYS2(虽然我只是做一个 pacman -Syu ,忽略所有错误并关闭窗口并打开一个新的,这是不推荐,你应该做安装工具链



    a)对于32位:



      pacman -S mingw-w64-i686-gcc 

    b)对于64位:

      pacman -S mingw-w64 -x86_64-gcc 


  • 安装您可能需要的任何库/工具。您可以通过执行以下操作搜索存储库:

      pacman -Ss name_of_something_i_want_to_install 

    例如

      pacman -Ss gsl 

    并使用

    安装

      pacman -S package_name_of_something_i_want_to_install 

    例如

      pacman -S minw-w64-x86_64-gsl 

    您的MinGW-w64 64位编译器会自动找到GSL库!


  • 打开MinGW-w64外壳:



    a)要构建32位的东西,打开MinGW-w64 32位Shell



    b)要构建64位的东西,打开MinGW-w64 64位Shell


  • 验证编译器是否正常工作

      gcc -v 


  • 如果你想在MSYS2环境之外使用工具链(已安装的库),你所需要做的就是添加< MSYS2 root> / mingw32 / bin < MSYS2 root> / mingw64 / bin 到您的 PATH


    I am trying to build some open source library. I need package management system to easily download the dependencies. At first I am using MinGW+MSYS. But the included packages are limited. Someone told me to use MinGW-w64 + MSYS2.

    I downloaded the mingw-w64-install from here. When running, it reports the following error. How to fix it?

    And btw, from the MinGW-w64 download page, I see a lot of download links. Even Cygwin is listed. How Cygwin and MinGW-w64 are related?

    My current understanding is, in the time of MinGW+MSYS, MSYS is just a nice addon to MinGW, while in MinGW-w64 + MSYS2, MSYS2 is standalone and MinGW-w64 is just a set of libraries it can work with. Just like Cygwin can download many different packges.

    解决方案

    Unfortunately, the MinGW-w64 installer you used sometimes has this issue. I myself am not sure about why this happens (I think it has something to do with Sourceforge URL redirection or whatever that the installer currently can't handle properly enough).

    Anyways, if you're already planning on using MSYS2, there's no need for that installer.

    1. Download MSYS2 from this page (choose 32 or 64-bit according to what version of Windows you are going to use it on, not what kind of executables you want to build, both versions can build both 32 and 64-bit binaries).

    2. After the install completes, click on the newly created "MSYS2 Shell" option under either MSYS2 64-bit or MSYS2 32-bit in the Start menu. Update MSYS2 according to the wiki (although I just do a pacman -Syu, ignore all errors and close the window and open a new one, this is not recommended and you should do what the wiki page says).

    3. Install a toolchain

      a) for 32-bit:

      pacman -S mingw-w64-i686-gcc
      

      b) for 64-bit:

      pacman -S mingw-w64-x86_64-gcc
      

    4. install any libraries/tools you may need. You can search the repositories by doing

      pacman -Ss name_of_something_i_want_to_install
      

      e.g.

      pacman -Ss gsl
      

      and install using

      pacman -S package_name_of_something_i_want_to_install
      

      e.g.

      pacman -S minw-w64-x86_64-gsl
      

      and from then on the GSL library is automatically found by your MinGW-w64 64-bit compiler!

    5. Open a MinGW-w64 shell:

      a) To build 32-bit things, open the "MinGW-w64 32-bit Shell"

      b) To build 64-bit things, open the "MinGW-w64 64-bit Shell"

    6. Verify that the compiler is working by doing

      gcc -v
      

    If you want to use the toolchains (with installed libraries) outside of the MSYS2 environment, all you need to do is add <MSYS2 root>/mingw32/bin or <MSYS2 root>/mingw64/bin to your PATH.

    这篇关于如何安装MinGW-w64和MSYS2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆