MSYS2 vs. MinGw64
MSYS vs. MinGW: internal environment variables
$ uname MSYS_NT-10.0 $ uname MINGW64_NT-10.0
Package Manager
$ pacman -Q <list all packages> $ pacman -Qi <package> <info about a single package> $ pacman -Ql <package> <files of a single package>
Pin to Taskbar
$ pacman -S msys2-launcher $ pacman -Qi msys2-launcher Name : msys2-launcher-git Version : 0.3.32.56c2ba7-2 Description : Helper for launching MSYS2 shells Architecture : x86_64 URL : None Licenses : MIT Groups : base Provides : msys2-launcher Depends On : mintty>=1~2.2.1 Optional Deps : None Required By : None Optional For : None Conflicts With : msys2-launcher Replaces : None Installed Size : 157.00 KiB Packager : Alexey Pavlov <alexpux@gmail.com> Build Date : Wed, Sep 7, 2016 7:59:07 PM Install Date : Thu, Apr 18, 2019 9:46:39 PM Install Reason : Explicitly installed Install Script : No Validated By : Signature $ pacman -Ql msys2-launcher msys2-launcher-git /mingw32.exe msys2-launcher-git /mingw32.ini msys2-launcher-git /mingw64.exe msys2-launcher-git /mingw64.ini msys2-launcher-git /msys2.exe msys2-launcher-git /msys2.ini
Update
MinGW coding under Windows (C, C++, OpenMP, MPI)
openFrameworks: msys2
$ pacman -Syu $ pacman -Su $ pacman -S base-devel $ pacman -S mingw-w64-x86_64-toolchain $ pacman -S git
fwrite()
fwrite() c function writing extra bytes
The difference in File access mode “w” and “wb”
// linux doesn't care... but windows does! FILE *fp = fopen(filename, "w"); // text mode // if streams includes 0x0A (\n) it prepends it with 0x0D (\r) FILE *fp = fopen(filename, "wb"); // binary mode
Keyring
Problem
$ pacman -Syu :: Synchronizing package databases... mingw32 mingw32.sig error: mingw32: key "5F944B027F7FE2091985AA2EFA11531AA0AA7F57" is unknown error: key "5F944B027F7FE2091985AA2EFA11531AA0AA7F57" could not be looked up remotely error: failed to update mingw32 (invalid or corrupted database (PGP signature)) mingw64 mingw64.sig error: mingw64: key "5F944B027F7FE2091985AA2EFA11531AA0AA7F57" is unknown error: key "5F944B027F7FE2091985AA2EFA11531AA0AA7F57" could not be looked up remotely error: failed to update mingw64 (invalid or corrupted database (PGP signature)) msys msys.sig error: msys: key "5F944B027F7FE2091985AA2EFA11531AA0AA7F57" is unknown error: key "5F944B027F7FE2091985AA2EFA11531AA0AA7F57" could not be looked up remotely error: failed to update msys (invalid or corrupted database (PGP signature)) error: failed to synchronize all databases
Solution
# rm -r /etc/pacman.d/gnupg/ # pacman-key --init # pacman-key --populate msys2 $ curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz $ curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig # pacman -U --config <(echo) msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz $ pacman -Syu :: Synchronizing package databases... mingw32 is up to date mingw64 is up to date msys is up to date :: Starting core system upgrade... [...]
arm-none-eabi
mingw-w64-arm-none-eabi-newlib
MINGW-packages wiki
MSYS2-packages
$ git clone https://github.com/Alexpux/MINGW-packages.git $ cd ~/MINGW-packages/mingw-w64-arm-none-eabi-binutils/ $ MINGW_INSTALLS=mingw64 makepkg-mingw -sLf $ pacman -U mingw-w64-x86_64-arm-none-eabi-binutils-2.24-1-any.pkg.tar.xz $ cd ~/MINGW-packages/mingw-w64-arm-none-eabi-gcc/ $ MINGW_INSTALLS=mingw64 makepkg-mingw -sLf ==> Making package: mingw-w64-gcc 4.8.4-1 (Sun, Mar 5, 2017 9:50:40 AM) ==> Checking runtime dependencies... ==> Installing missing dependencies... error: target not found: mingw-w64-x86_64-arm-none-eabi-newlib ==> ERROR: 'pacman' failed to install missing dependencies. $ cd ~/MINGW-packages/mingw-w64-arm-none-eabi-newlib/ $ MINGW_INSTALLS=mingw64 makepkg-mingw -sLf ==> Making package: mingw-w64-newlib 2.1.0-1 (Sun, Mar 5, 2017 9:51:25 AM) ==> Checking runtime dependencies... ==> Checking buildtime dependencies... ==> Retrieving sources... [...] /bin/sh ../../gcc/gcc/../move-if-change tmp-mlib.h multilib.h echo timestamp > s-mlib rm cpp.pod gcov.pod fsf-funding.pod gfdl.pod make[1]: Leaving directory '/home/bachman0/MINGW-packages/mingw-w64-arm-none-eabi-newlib/src/build-gcc-x86_64-w64-mingw32/gcc' make: *** [Makefile:3892: all-gcc] Error 2 ==> ERROR: A failure occurred in prepare(). Aborting...
List of files installed by a package
$ pacman -Ql mingw-w64-x86_64-arm-none-eabi-binutils [...] mingw-w64-x86_64-arm-none-eabi-binutils /mingw64/bin/arm-none-eabi-addr2line.exe mingw-w64-x86_64-arm-none-eabi-binutils /mingw64/bin/arm-none-eabi-ar.exe mingw-w64-x86_64-arm-none-eabi-binutils /mingw64/bin/arm-none-eabi-as.exe mingw-w64-x86_64-arm-none-eabi-binutils /mingw64/bin/arm-none-eabi-ld.exe mingw-w64-x86_64-arm-none-eabi-binutils /mingw64/bin/arm-none-eabi-objcopy.exe mingw-w64-x86_64-arm-none-eabi-binutils /mingw64/bin/arm-none-eabi-objdump.exe mingw-w64-x86_64-arm-none-eabi-binutils /mingw64/bin/arm-none-eabi-readelf.exe mingw-w64-x86_64-arm-none-eabi-binutils /mingw64/bin/arm-none-eabi-strip.exe [...]
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. These programs are built to co-operate well with other Windows programs, independently of the other subsystems.
The msys2
subsystem provides an emulated mostly-POSIX-compliant environment for building software, package management, and shell scripting. These programs live in a virtual single-root filesystem (the root is the MSYS2 installation directory). Some effort is made to have the programs work well with native Windows programs, but it’s not seamless.
Each of the subsystems provides its own native (i.e. target=host) compiler toolchain, in msys2-devel
, mingw-w64-i686-toolchain
, and mingw-w64-x86_64-toolchain
. There are also cross compiler toolchains with host={i686,x86_64}-pc-msys
and target={i686,x86_64}-w64-mingw32
in mingw-w64-cross-toolchain
, but these are of limited use because there are no library packages for them.
Every subsystem has an associated “shell”, which is essentially a set of environment variables that allow the subsystems to co-operate properly. These shells can be invoked using scripts in the MSYS2 installation directory or shortcuts in the Start menu. The scripts set the MSYSTEM variable and start a terminal emulator with bash. Bash in turn sources /etc/profile
which sets the environment depending on the value of MSYSTEM.
Update MSYS2
ssh not finding ssh config or IdentityFile
$ pacman -Sy :: Synchronisiere Paketdatenbanken... mingw32 291,3 KiB 867K/s 00:00 [#####################] 100% mingw32.sig 96,0 B 0,00B/s 00:00 [#####################] 100% mingw64 290,9 KiB 1672K/s 00:00 [#####################] 100% mingw64.sig 96,0 B 0,00B/s 00:00 [#####################] 100% msys 135,6 KiB 11,0M/s 00:00 [#####################] 100% msys.sig 96,0 B 0,00B/s 00:00 [#####################] 100% $ pacman --needed -S bash pacman msys2-runtime (1/3) Aktualisiere msys2-runtime [#####################] 100% (2/3) Aktualisiere bash [#####################] 100% (3/3) Aktualisiere pacman [#####################] 100% $ exit $ pacman -Su :: Starting core system upgrade... [...] WARNING: the shell starting scripts have been unified. Please update your shortcuts to the following targets, otherwise they will STOP WORKING: * MSYS2_ROOT\msys2_shell.cmd -mingw32 * MSYS2_ROOT\msys2_shell.cmd -mingw64 * MSYS2_ROOT\msys2_shell.cmd -msys [...] $ exit Update Links => .bat to .cmd $ pacman -S openssh $ pacman -S git $ pacman -h -S Verwendung: pacman {-S --sync} [Optionen] [Paket(e)] Optionen: -b, --dbpath <Pfad> Setzt einen anderen Ort für die Datenbank -c, --clean Entfernt alte Pakete aus dem Paketpuffer (-cc für alle) -d, --nodeps Überspringt die Versionsüberprüfungen für Abhängigkeiten (-dd um alle Überprüfungen zu überspringen) -g, --groups Zeigt alle Mitglieder einer Paket-Gruppe an (-gg um alle Gruppen samt Mitgliedern anzuzeigen) -i, --info Zeigt Paketinformationen an (-ii für erweiterte Informationen) -l, --list <repo> Zeigt eine Liste aller Pakete eines Repositoriums an -p, --print Zeigt die Ziele an, statt die Operation auszuführen -q, --quiet Zeigt weniger Information bei Abfragen und Suche an -r, --root <Pfad> Setzt ein alternatives Wurzelverzeichnis zur Installation -s, --search <regex> Durchsucht entfernte Repositorien nach einem Wort -u, --sysupgrade Aktualisiert installierte Pakete (-uu ermöglicht Downgrades) -v, --verbose Sei gesprächig -w, --downloadonly Lädt Pakete herunter, ohne etwas zu installieren oder aktualisieren -y, --refresh Lädt aktuelle Paketdatenbanken vom Server herunter (-yy um eine Aktualisierung auch bei aktuellen Datenbanken durchzuführen) --arch <arch> Setzt eine alternative Architektur --asdeps Installiert Pakete als nicht-ausdrücklich installiert --asexplicit Installiert Pakete als ausdrücklich installiert --assume-installed <package=version> Fügt ein virtuelles Paket hinzu, um Abhängigkeiten zu erfüllen --cachedir <Verzeichnis> Setzt einen anderen Ort für den Paketpuffer --color <wann> Ausgabe farbig darstellen --config <Pfad> Setzt eine alternative Konfigurationsdatei --confirm Immer nach einer Bestätigung fragen --dbonly Verändert nur Datenbank-Einträge, keine Paketdateien --debug Zeigt Debug-Meldungen an --force Installation erzwingen, Dateikonflikte überschreiben --gpgdir <path> Setzt alternatives Konfigurationsverzeichnis für GnuPG --hookdir <dir> setze ein anderes Hook-Verzeichnis --ignore <pkg> Ignoriert ein neues Paket (kann mehrfach genutzt werden) --ignoregroup <grp> Ignoriert Upgrade einer Gruppe (kann mehrfach genutzt werden) --logfile <Pfad> Setzt eine alternative Log-Datei --needed Installiert aktuelle Pakete nicht erneut --noconfirm Niemals nach einer Bestätigung fragen --noprogressbar Keine Fortschrittsanzeige anzeigen, wenn Dateien heruntergeladen werden --noscriptlet Installationsskript nicht ausführen, falls vorhanden --print-format <string> Legt fest, wie die Ziele ausgegeben werden sollen
C:\msys64\msys2_shell.bat’ is not recognized as an internal or external command
Current installer/installation instructions are broken
==> update links. Don’t use msys2_shell.bat but msys2_shell.cmd
Install Python NumPy
Practical Computing for Biologists – Setting up Windows and Linux
# download MSYS2 (Arch Linux) https://msys2.github.io/ # Choose the version that says x86_64, not i686 # Update system pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime # Restart MSYS # (Close all windows and reopen from start menu) # All Programs > MSYS2 64-bit > MSYS Shell pacman -Su # You might get some errors. If so, just run the command again and it should pick up the slack. #install python and other utilities # REQUIRED pacman --noconfirm -S gcc python2 man nano sqlite vim git bc tar # This can take a while to download # Note: To search for other package locations, use pacman -Ss <package_name> Then to install, copy the name (before the version number) after a pacman -Sy command... # issues: sudo and screen not there in default pacman... # NEXT you should do these commands: cd /usr/bin ln -sf python2 python cd # Then install pip using these steps: mkdir ~/scripts cd ~/scripts curl -O 'https://bootstrap.pypa.io/get-pip.py' ./get-pip.py # If that succeeds (which pip should now find something) then.. rm get-pip.py # Now to use the installer for grabbing python packages like numpy, Biopython, and beautifulSoup: pip install numpy ########################## Working in MSYS2 Your home directory, as we refer to it in the book, will be /home/lucy in the terminal window, but it lives in the c:\msys32 (or msys64) folder. You could make a shortcut from the folder here with our username to the Windows desktop for easy cross-platform access. # MSYS2 starts with an annoying multi-line prompt, so edit your .bash_profile using this command nano ~/.bash_profile # Note that <ctrl>C will not work for copying in the terminal, because it has another function. # Right click to copy/paste from the pop-up menu # Add the following four lines to your .bash_profile PS1='\[\e[1;32m\]\u:\[\e[1;36m\]\w \$ \e[0m' export PATH=$PATH:$HOME/scripts export EDITOR=/usr/bin/nano set -o noclobber ################################ Next, in Windows, install the GUI Install <a href="http://www.sublimetext.com/3">Sublime Text 3</a> After installation, Change color scheme to iPlastic To get the command-line option (so you can edit files from the terminal by typing 'subl' google the page about changing your System Path to work with Sublime Text 3. ##############################
Difference between native python and mingw-w64 python.
Numpy Mingw w64 FAQ
Anaconda – open data science platform
Conda – open source package management system
Install mingw-w64-x86_64 packages
$ pacman -S mingw-w64-x86_64-python3 [...] (24/24) checking for file conflicts [####################################################################] 100% error: failed to commit transaction (conflicting files) mingw-w64-x86_64-gmp: /mingw64 exists in filesystem [...]
Msys2 + Windows 10 + pacman errors
$ mkdir /mingw64
Change language
$ export LC_ALL=en_US.UTF-8
No C Compiler installed
$ python3 setup.py install running install running build running build_py creating build creating build/lib.mingw-3.5 creating build/lib.mingw-3.5/bigfloat copying bigfloat/context.py -> build/lib.mingw-3.5/bigfloat copying bigfloat/core.py -> build/lib.mingw-3.5/bigfloat copying bigfloat/ieee.py -> build/lib.mingw-3.5/bigfloat copying bigfloat/rounding_mode.py -> build/lib.mingw-3.5/bigfloat copying bigfloat/__init__.py -> build/lib.mingw-3.5/bigfloat creating build/lib.mingw-3.5/bigfloat/test copying bigfloat/test/test_bigfloat.py -> build/lib.mingw-3.5/bigfloat/test copying bigfloat/test/test_context.py -> build/lib.mingw-3.5/bigfloat/test copying bigfloat/test/test_mpfr.py -> build/lib.mingw-3.5/bigfloat/test copying bigfloat/test/test_rounding_mode.py -> build/lib.mingw-3.5/bigfloat/test copying bigfloat/test/test___all__.py -> build/lib.mingw-3.5/bigfloat/test copying bigfloat/test/__init__.py -> build/lib.mingw-3.5/bigfloat/test running build_ext Traceback (most recent call last): File "setup.py", line 267, in <module> 'bigfloat.test', File "C:/msys64/mingw64/lib/python3.5\distutils\core.py", line 148, in setup dist.run_commands() [...] File "C:/msys64/mingw64/lib/python3.5\distutils\ccompiler.py", line 1033, in new_compiler return klass(None, dry_run, force) File "C:/msys64/mingw64/lib/python3.5\distutils\cygwinccompiler.py", line 288, in __init__ CygwinCCompiler.__init__ (self, verbose, dry_run, force) File "C:/msys64/mingw64/lib/python3.5\distutils\cygwinccompiler.py", line 127, in __init__ if self.ld_version >= "2.10.90": TypeError: unorderable types: NoneType() >= str() $ pacman -S mingw-w64-x86_64-gcc $ python3 setup.py install running install running build running build_py running build_ext building 'mpfr' extension creating build/temp.mingw-3.5 C:\msys64\mingw64\bin/x86_64-w64-mingw32-gcc.exe -Wno-unused-result -Wsign-compare -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -DNDEBUG -IC:/msys64/mingw64/include/python3.5m -c mpfr.c -o build/temp.mingw-3.5/mpfr.o [...] Writing C:/msys64/mingw64/lib/python3.5/site-packages/bigfloat-0.3.0-py3.5.egg-info
pacman install build system for mingw-w64-x86_64
$ pacman -S mingw-w64-x86_64-gcc $ pacman -S mingw-w64-x86_64-gdb
pacman query
How can I show the list of all installed packages in Arch Linux (pacman packet manager)?
-Q, --query Query the package database. This operation allows you to view installed packages and their files, as well as meta-information about individual packages -i, --info Display information on a given package. -s, --search <regexp> Search each locally-installed package for names or descriptions that match regexp.
$ pacman -Qi mingw-w64-x86_64-python3 Name : mingw-w64-x86_64-python3 Version : 3.5.2-2 $ pacman -Qs python local/mingw-w64-x86_64-python3 3.5.2-2 A high-level scripting language (mingw-w64) local/mingw-w64-x86_64-python3-cairo 1.10.0-5 Python2 bindings for the cairo graphics library (mingw-w64) local/mingw-w64-x86_64-python3-cycler 0.9.0-1 Composable style cycles [...]
$ pacman -Ss xpdf mingw32/mingw-w64-i686-poppler 0.76.1-1 PDF rendering library based on xpdf 3.0 (mingw-w64) mingw32/mingw-w64-i686-xpdf 4.00-1 Utilities for PDF files (mingw-w64) mingw64/mingw-w64-x86_64-poppler 0.76.1-1 PDF rendering library based on xpdf 3.0 (mingw-w64) mingw64/mingw-w64-x86_64-xpdf 4.00-1 Utilities for PDF files (mingw-w64) [...]
$ pacsearch python2
$ pacman -R mingw-w64-x86_64-arm-none-eabi-binutils
MSYS2 Shell vs MinGW-w64 Shell
MSYS2 Shell or MinGW-w64 Shell
MSYS2-Introduction
How does MSYS2 differ from Cygwin?
MSYS2
MSYS2 is based on Cygwin and knows how to understand POSIX conventions like paths (/usr/bin/
, /etc
) as well as special devices like /dev/null
, /dev/clipboard
, etc and many other things. MSYS2 comes with a GCC toolchain who will produce native binaries that are always tied to msys-2.0.dll
. It’s that DLL that does all the magic of interoperability between POSIX conventions and Windows. It’s because of it that it’s possible to use a Unix like path /home/joe/
and pass it to a Windows and it still works.
Indeed, (I’m not sure of the exact details) but when when msys-2.0.dll
sees you are calling a native Windows executables (one that does not
depends on msys-2.0.dll
), it will convert the path /home/joe/
to a
Windows path like C:\Users\joe
that the native Windows program receives
and knows how to understand. Without this translation, the Windows program
would receive /home/joe/
and wouldn’t understand how to treat it
correctly. All this paths translations applies also to environment
variables.
This process (and all the POSIX emulation layer) incurs a performance
penalty that can be significant for heavy file-centric software. Git is a
good example and that’s why the MSYS2 git package (msys/git
) is slower
than a native git client like the one provided by Git For Windows
(git-for-windows/mingw-w64-x86_64-git
). That’s why a native program (read
a MINGW one) is usually “better” than an MSYS2 one. Don’t be afraid of
using pure MSYS2 program, in most cases (I would say 90%), the difference
is not significant because bottleneck is not the filesystem (CPU, network,
other).
That’s why you will often read that MSYS2 is only a way to make it easier
to build and deploy MINGW native executables. In my personal opinion and
the way I use it, it’s much much more than that as I use and build little
MINGW tools. MSYS2 is a full subsystem dealing with way more than just a
toolchain as it deals with filesystem, users, permissions (to an extent)
and much more. I use it mainly because it has the same toolset as the one
I’m used on Linux (console-based of course :)).
Because MSYS2 understands POSIX and has a pretty good emulation layer, it
is often very easy to port a package originally built on Linux to it,
because almost no code work is needed.
MINGW
MINGW (either 32 or 64) is a set of toolchain to build native Windows
program. Those program do not depends on msys-2.0.dll
and depends rather
on MSVC runtime. Those don’t understand POSIX paths, so if you pass
/home/joe
outside of an MSYS2 shells (from pure cmd for example), it will
not understand it. Indeed, in pure cmd
(and via many interactions from
other programs), no translation of paths is performed.
MINGW toolchains are based on mingw-w64 which
provides the ground work to compile them. They are available in pacman for
installation and they also contains GCC et related tools (binutils, ld).
When invoked, GCC produces pure native executable. So, when working with a
MINGW program, remember that it’s like a native Window program that knows
nothing about MSYS2.
MSYS2 happens to actual provides those toolchains directly to you
pre-compiled via pacman. Note however, that it’s possible to download the
mingw-w64 toolchains in standalone, put them somewhere and invoke them
afterward in MSYS2 (by proprely configuring PATH and other variables
yourself). They can also be invoked via cmd
directly because they do not
depend on MSYS2 at all.
Shells
When you start any of the MSYS2 shells, they all start an MSYS2 bash
program. Since it’s a MSYS2 bash
, it understands Unix paths and will do
translation when calling native Windows executables.
That being said, what is the difference between all the shells? It all
about the tweaking some environment variables to change default programs
picked when calling them. It’s mainly about the PATH environment variable
but it also involves MSYSTEM PKG_CONFIG_PATH ACLOCAL_PATH MANPATH like Ray
said earlier. Checkout /etc/profile
around line 28 to see the conditional
that sets all this.
Let’s assume you have installed three toolchains:
* MSYS2 (package group msys2-devel
) to compile MSYS2 tools which
installs gcc in /usr/bin
.
* MINGW32 (package group mingw-w64-i686-toolchain
) to compile Windows
native 32 bits executable which installs gcc in /mingw32/bin
.
* MINGW64 (package group mingw-w64-x86_64-toolchain
) to compile
Windows native 64 bits executable which installs gcc in /mingw64/bin
.
For msys2_shell, PATH is roughly only /usr/local/bin:/usr/bin:/bin
. This
means that when running gcc
, you will get /usr/bin/gcc
.
For mingw32_shell, PATH is roughly
/mingw32/bin:/usr/local/bin:/usr/bin:/bin
. This means that now, running
gcc
you will get instead /mingw32/bin/gcc
.
For mingw64_shell, PATH is roughly
/mingw64/bin:/usr/local/bin:/usr/bin:/bin
and as you have guessed,
running gcc
you will get instead /mingw64/bin/gcc
.
This means that all three shells have the same capabilities, but because of
the different orders, tools that will be picked are different. So, if you
want to compile something, use the appropriate shell for what you want to
do (MSYS2 program, Windows native 32 bits or Windows native 64 bits).
If you are not compiling anything, then it depends. Usually, msys2_shell is
recommended. However, on a bare installation, /mingw64/bin
is not added
anywhere when using msys2_shell
, problem it can causes is that if you had
installed mingw64 packages, they are not available in the shell. In my
case, I have tweaked by .bash_profile
to correctly add /mingw64/bin
after PATH (like /usr/local/bin:/usr/bin:/bin:/mingw64/bin
). This
always favor MSYS2 tools but will pick /mingw64/bin
when they don’t exist
in MSYS2 /usr/bin
.