Thursday, September 3, 2020


MSYS2
Software Distribution and Building Platform for Windows
Understanding the two build environments: mingw32 and mingw64

The mingw32.exe shell will automatically target the 32-bit compiler. So, you'll simply have to launch ming32 in order to build any 32-bit executable.
The C:\dev\msys64\mingw32 folder is the base directory for all 32-bit software. It will be internally mapped by MSYS2 as /mingw32

The mingw64.exe shell will automatically target the 64-bit compiler. So, you'll simply have to launch ming64 in order to build any 64-bit executable.
The C:\dev\msys64\mingw64 folder is the base directory for all 64-bit software. It will be internally mapped by MSYS2 as /mingw64

In order to maintain a properly ordered filesystem layout, clearly separating 32-bit and 64-bit components we can't any longer adopt the classic /usr/local target as the standard destination where to install our custom builds.

/mingw32/local
this will be the directory where to install all 32-bit builds.
/mingw64/local
and this will be the directory where to install all 64-bit builds.

Installation
Download the installer: msys2-x86_64-20200720.exe
SHA256 checksum: ad6b58b355a852d9df7c6dc2722d0eca139042cf262ae7363e0a5e7dd2a6c5c9
Run the installer. MSYS2 requires 64-bit Windows 7 or newer.
Click "Next"
Enter Installation Folder (ASCII, no accents, spaces nor symlinks, short path)
Tick Run MSYS2 now
Update the package database and core system packages with:
pacman -Syu
If needed, close MSYS2, run it again from Start menu. Update the rest with:
pacman -Su
Now Pacman is fully committed to the Windows cause :)






Pacman


Familiarizing with Pacman


After properly installing MSYS2 you'll be able to use pacman in order to complete your installation.
Pacman is a package manager similar to Red Hat's 
yum and Debian's apt-get, and will make really easy the task to prepare a complete build environment.

  1. Start an MSYS2 shell.
    Just click the icon of one between 
    msys2.exemingw32i.exe or mingw64.exe you'll find into the C:\dev\msys64 folder (the one or the other is not relevant in this context).
  2. Then execute the following commands from the shell:
    • pacman -S --needed base-devel
      This will install 
      makepkg-config and many others useful tools.
    • pacman -S --needed mingw-w64-i686-toolchain
      This will install the 
      32-bit compiler.
    • pacman -S --needed mingw-w64-x86_64-toolchain
      This will install the 64-bit compiler.
    • pacman -S --needed mingw-w64-i686-cmake mingw-w64-x86_64-cmake
      This will install 
      CMake for both 32 and 64 bits.
  3. all right: you've now completed your MinGW64 + MSYS2 installation, and you are ready to start building your Windows binary executables.
Note: may well be you'll discover before or after that some tool is still missing. You can easily install it when required.
Example: the well-known 
vim text editor is still missing; you can easily install it by executing: pacman -S vim
Hint: you can easily check all packages declaring a matching name and if they are already installed or not by executing: 
pacman -Ss package-name:


The MinGW64 + MSYS2 Environment To Install Fortran


MinGW64 is an open source C/C++ compiler for Windows platforms based on the popular gcc available on Linux and on many other Operating Systems; Mingw64 can create both 32 and 64 bit binary executables.
MSYS2 is a command shell supporting a minimalistic Linux-like environment on Windows.
Using both them you can build standard open source software [originally developed for Linux] under Windows as well, simply using the classic build tool-chain, as in:

./configure
make
make install

Install MSYS2 from http://www.msys2.org/

Once MSYS2 is installed, it will open a shell. Update repositories with:
pacman -Syu

To search of a package called e.g. gfortran use:
pacman -Ss gfortran

Install compilers
pacman -S mingw64/mingw-w64-x86_64-gcc-fortran mingw64/mingw-w64-x86_64-gcc