MSYS2 / MSYS / MinGW

From miki
Jump to navigation Jump to search

This page is about:

  • MSYS, MSYS is a collection of GNU utilities such as bash, make, gawk and grep on Windows.
  • MinGW, "Minimalist GNU for Windows". MinGW is a minimalist development environment for native Microsoft Windows applications.
  • MSYS2, a Cygwin-derived software distro for Windows using Arch Linux's Pacman. MSYS2 is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software.

MSYS and MinGW are mostly inactive now. MSYS2 is the active alternative.

References

MSYS2
  • Pacman rosetta, find the corresponding pacman command from those used in popular Linux distribution.
MSYS / MinGW

Development

gcc vs MinGW-64 gcc

MSYS2 comes with three flavors of gcc [1]:

  • Standard gcc, installed in /usr/bin, and relying on msys-2.0.dll.
  • MinGW gcc targetting 64-bit Windows application, installed in /mingw64/bin.
  • MinGW gcc targetting 32-bit Windows application, installed in /mingw32/bin.

Tips

Install package

Use pacman:

pacman -S git

Install/update MSYS2 packages on offline computer

MSYS2 can be installed and updated on a computer that has no internet connection. It only requires a secondary computer with internet access. We follow the procedure on SO:

On the computer with internet access
mkdir ~/offline_packages
cd ~/offline_packages
pacman -Syw base base-devel mingw-w64-x86_64-toolchain --cachedir .
find -newer offline.db.tar.gz -name "*.xz" | xargs repo-add offline.db.tar.gz

Now copy offline_packages to an external storage device.

On offline computer
  • Install MSYS2.
  • Copy offline_packages to a path that MSYS2 can access (for instance C:/msys64/home/user/offline_packages)
  • Edit C:/msys64/etc/pacman.conf:
  • Comment out the [mingw32], [mingw64], [msys] repositories.
  • Add a new section (update as necessary):
[offline]
SigLevel = Optional
Server = file:///home/user/offline_packages
  • Then in an MSYS2 terminal:
pacman -Syu
pacman -S --needed base base-devel mingw-w64-x86_64-toolchain

Later on, we can update the database, either adding new package or replacing one with a newer version.

On computer with internet access
pacman -Syw liblz4 procps python3 --cachedir .
repo-add ./offline.db.tar.gz liblz4-1.8.2-1-x86_64* procps-3.2.8-2-x86_64* python-3.6.6-1-x86_64*
On offline computer

Update the repository with the newer files, and update the offline computer as usual.

cp -ruv offline_packages /home/user
pacman -Syu
pacman -S --needed procps python3
Troubleshooting

Above is the theory, in practice, pacman sometimes does not download all dependency packages, and these must be downloaded manually. In that case look at missing dependencies in the error message, and download these packages explicitly.

More information:

Troubleshooting

msys2 gcc error 1

Starting make, we get the error:

make: *** [build] Error 1

The error is due to a conflicting msys-2.0.dll found in the path. Search for all similar DLL, and make sure none are lying around, except for the one in c:\msys64.

msys2 startup very slow

The fix is to remove db from file /etc/nsswitch.conf, and optionally create files /etc/passwd and /etc/group

mkpasswd -l -c > /etc/passwd    # Avoid username Unknown+User
mkgroup -l -c > /etc/group
sed -ri 's/^(passwd:).*/\1 files # db/; s/^(group:).*/\1 files # db/' /etc/nsswitch.conf

Source: