113

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

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

Enter image description here

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

Enter image description here

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

4 Answers 4

258

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.

  2. After the install completes, click on the MSYS2 UCRT64 in the Start menu (or C:\msys64\ucrt64.exe).

    If done correctly, the terminal prompt will say UCRT64 in magenta letters, not MSYS.

  3. Update MSYS2 using pacman -Syuu. If it closes itself during the update, restart it and repeat the same command to finish the update.

    You should routinely update your installation.

  4. Install the toolchain: (i.e. the compiler and some extra tools)

    pacman -S mingw-w64-ucrt-x86_64-toolchain
    
  5. 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-ucrt-x86_64-gsl
    

    and from then on the GSL library will be automatically found by your compiler!

    Make sure any compilers and libraries you install have this package prefix: mingw-w64-ucrt-x86_64-. Only use unprefixed packages for misc command-line utilities (such as grep, sed, make, etc), unless you know what you're doing.

  6. Verify that the compiler is working by doing

    gcc --version
    

If you want to use the toolchains (with installed libraries) outside of the MSYS2 environment, all you need to do is add C:/msys64/ucrt64/bin to your PATH.

MSYS2 provides several compiler flavors, UCRT64 being one of them. It should be a reasonable default.

15
  • 5
    Thanks. How can I get the canonical name of a package that pacman can recognize? May 6, 2015 at 12:30
  • 1
    Will it work if you install both 32 and 64 bit toolchains simultaneously? Sep 28, 2015 at 18:00
  • 2
    @Colonel yes, it will install the toolchains (and any 3rd party libraries you install) in separate directories (/mingw32 and /mingw64).
    – rubenvb
    Sep 29, 2015 at 6:23
  • 1
    To use in MSYS2 shell I had to do: PATH=/mingw64/bin:$PATH Mar 30, 2016 at 22:55
  • 2
    Using pacman to install mingw-w64 is a great advice. I faced the same issue while trying to install mingw-w64 behing a proxy. Installing MSYS2 first, setting environment variables for the proxy like superuser.com/questions/713582/… and following your answer works perfectly.
    – francis
    Aug 19, 2016 at 11:22
58

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

To install the MinGW-w64 toolchain (reference):

  1. Open the MSYS2 shell from the start menu
  2. Run pacman -Sy pacman to update the package database
  3. Reopen the shell, and run pacman -Syu to update the package database and core system packages
  4. Reopen the shell, and run pacman -Su to update the rest
  5. Install the compiler:
    • For a 32-bit target, run pacman -S mingw-w64-i686-toolchain
    • For a 64-bit target, run pacman -S mingw-w64-x86_64-toolchain
  6. Select which package to install; the default is all
  7. You may also need make. Run pacman -S make
6
  • 3
    how do i install specific MinGW-w64 version like x86_64-6.2.0-release-posix-seh-rt_v5-rev1?
    – Youda008
    Dec 8, 2016 at 14:12
  • 1
    Does that mean the mingw installer as described here is not necessary anymore? and I should just install msys2?
    – lanoxx
    Feb 17, 2017 at 10:45
  • 1
    Link Reference is broken Sep 11, 2017 at 6:59
  • any ideas on why msys2 shell would close itself after a second?
    – A_P
    May 9, 2019 at 22:36
  • 3
    In case you need cmake, you have to install pacman -S mingw-w64-x86_64-cmake and NOT cmake. Normal cmake will lack generators for minGW.
    – user136036
    Jan 15, 2020 at 19:57
4

You can now also get the stand-alone personal build of MinGW-w64 from https://winlibs.com/ which doesn't require any installation; just extract and its ready to use. This allow having multiple toolchains on the same system (e.g., one for Windows 32-bit and another for Windows 64-bit).

2
  • MSYS2 also supports multiple toolchains per installation (and multiple installations). Winlibs is indeed easy to use, but lacks a package manager (i.e. no prebuilt libraries) and a linux-like environment (can't build stuff using Autotools). Nov 23, 2021 at 19:07
  • 1
    @HolyBlackCat Thanks for your insights. I'm actually working on a package manager for winlibs, and I'm making it cross-platform. Nov 23, 2021 at 22:15
0

The most straightforward way, as far as I know, is to use Chocolatey to install MinGW:

choco install mingw

Then check with the command whereis gcc. It is going to be installed in C:\ProgramData\chocolatey\bin.

one more thing, to get make working, just copie (or rename if you wish) with copy mingw32-make.exe make.exe in C:\ProgramData\chocolatey\bin.

4
  • Re "to be installed in C:\ProgramData": Doesn't that depend on the Windows version and the configuration of Windows? Dec 10, 2022 at 15:13
  • mingw32-make and make are different things, and pretending one is the other won't do any good. Dec 10, 2022 at 21:39
  • Does this install pacman (the package manager)? One of the main selling points of MSYS2 is its numerous packages... Dec 10, 2022 at 21:40
  • 1
    mingw32-make is a version of make that has been ported to Windows with MinGW. It works in a similar way to make, but with some differences in syntax and behavior due to Windows difference.
    – JGaber
    Apr 9 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.