Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 756
smwikipedia Avatar asked May 06 '15 07:05

smwikipedia


People also ask

Does MSYS2 include MinGW?

MSYS2 consists of three subsystems and their corresponding package repositories, msys2 , mingw32 , and mingw64 . The mingw subsystems provide native Windows programs and are the main focus of the project.

How do I add MSYS2 to path?

Adding MSYS2 to your PATH variableClick on the “Environment Variables” button. In the “System Variables” section, scroll down and double-click on the “Path” variable. If you're on Windows 7/8, add the text C:\msys32\usr\bin;C:\msys32\usr\local\bin; to the beginning of the variable value.


1 Answers

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 newly created "MSYS2 Shell" option under either MSYS2 64-bit or MSYS2 32-bit in the Start menu (or mingw64.exe or mingw32.exe in the installation directory).

    If done correctly, the terminal prompt will say MINGW64 or MINGW32 respectively, 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 a toolchain

    a) for 64-bit:

    pacman -S mingw-w64-x86_64-toolchain 

    b) for 32-bit:

    pacman -S mingw-w64-i686-toolchain 

    This includes GCC (the compiler), GDB (the debugger), and more.

  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-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-x86_64- for 64-bit or mingw-w64-i686- for 32-bit). 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 <MSYS2 root>/mingw64/bin or <MSYS2 root>/mingw32/bin to your PATH.

like image 142
rubenvb Avatar answered Sep 18 '22 00:09

rubenvb