[cygwin] How to install MinGW-w64 and MSYS2?

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?

enter image description here

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?

enter image description here

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.

This question is related to cygwin mingw msys mingw-w64 msys2

The answer is


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 mingw-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.


MSYS has not been updated a long time, MSYS2 is more active, you can download from MSYS2, it has both mingw and cygwin fork package.

To install the MinGW-w64 toolchain (Reference):

  1. Open MSYS2 shell from start menu
  2. Run pacman -Sy pacman to update the package database
  3. Re-open the shell, run pacman -Syu to update the package database and core system packages
  4. Re-open the shell, run pacman -Su to update the rest
  5. Install compiler:
    • For 32-bit target, run pacman -S mingw-w64-i686-toolchain
    • For 64-bit target, run pacman -S mingw-w64-x86_64-toolchain
  6. Select which package to install, default is all
  7. You may also need make, run pacman -S make

Examples related to cygwin

How to install MinGW-w64 and MSYS2? Split text file into smaller multiple text file using command line fatal: early EOF fatal: index-pack failed Git Extensions: Win32 error 487: Couldn't reserve space for cygwin's heap, Win32 error 0 How to cd into a directory with space in the name? Git push hangs when pushing to Github? Running a shell script through Cygwin on Windows Running Git through Cygwin from Windows .ssh directory not being created Cygwin - Makefile-error: recipe for target `main.o' failed

Examples related to mingw

MINGW64 "make build" error: "bash: make: command not found" How to install MinGW-w64 and MSYS2? printf, wprintf, %s, %S, %ls, char* and wchar*: Errors not announced by a compiler warning? mingw-w64 threads: posix vs win32 Serial Port (RS -232) Connection in C++ What is difference between sjlj vs dwarf vs seh? Unable to specify the compiler with CMake to_string is not a member of std, says g++ (mingw) How to compile makefile using MinGW? Getting started with OpenCV 2.4 and MinGW on Windows 7

Examples related to msys

How to install MinGW-w64 and MSYS2? Where can I set path to make.exe on Windows?

Examples related to mingw-w64

How to install MinGW-w64 and MSYS2? What is difference between sjlj vs dwarf vs seh?

Examples related to msys2

Change the location of the ~ directory in a Windows install of Git Bash How to install MinGW-w64 and MSYS2?