Skip to content

week1.md

feliciachou edited this page Jun 15, 2022 · 1 revision

MSYS2

MSYS2 is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software.

It consists of a command line terminal called mintty, bash, version control systems like git and subversion, tools like tar and awk and even build systems like autotools, all based on a modified version of Cygwin. Despite some of these central parts being based on Cygwin, the main focus of MSYS2 is to provide a build environment for native Windows software and the Cygwin-using parts are kept at a minimum. MSYS2 provides up-to-date native builds for GCC, mingw-w64, CPython, CMake, Meson, OpenSSL, FFmpeg, Rust, Ruby, just to name a few.

GCC

The GNU Compiler Collection (GCC) is an optimizing compiler produced by the GNU Project supporting various programming languages, hardware architectures and operating systems. The Free Software Foundation (FSF) distributes GCC as free software under the GNU General Public License (GNU GPL). GCC is a key component of the GNU toolchain and the standard compiler for most projects related to GNU and the Linux kernel.

GCC has been ported to more platforms and instruction set architectures than any other compiler, and is widely deployed as a tool in the development of both free and proprietary software. GCC is also available for many embedded systems, including ARM-based and Power ISA-based chips.

Installing and running MSYS2

Download MSYS2 from http://www.msys2.org/. Download the .exe file and follow the installation instructions on the site. After installing, navigate to the directory where it was installed, and run msys2.exe. For this tutorial, we will assume the default location of C:\msys64. After opening it you should find yourself in a bash shell.

Updating MSYS2

MSYS2 uses the pacman package manager that the Arch Linux distribution uses. After your initial install it is a good idea to update all the packages. Update everything using:

pacman -Syu

Installing gcc using MSYS2

In the MSYS2 bash shell, use pacman again to install the build toolchain and compilers. Run the command below to install the mingw-w64-x86_64-toolchain package group.

Install make, autoconf, etc to C:\msys64\usr\bin
pacman -S base-devel gcc vim cmake

Note that vim and cmake are optional, but handy to have. Here is the list of packages that are installed with the above. After installing those packages, you will have gcc and the other tools available to be used while in the MSYS2 shell. If you want to use them in the command prompt or otherwise outside of the MSYS2 shell, they are available in the C:\msys64\usr\bin directory.

   pacman -S base-devel
   1) asciidoc  2) autoconf  3) autoconf2.13  4) autogen  5) automake-wrapper
   6) automake1.10  7) automake1.11  8) automake1.12  9) automake1.13
   10) automake1.14  11) automake1.15  12) automake1.16  13) automake1.6
   14) automake1.7  15) automake1.8  16) automake1.9  17) bison  18) diffstat
   19) diffutils  20) dos2unix  21) file  22) flex  23) gawk  24) gdb
   25) gettext  26) gettext-devel  27) gperf  28) grep  29) groff  30) help2man
   31) intltool  32) lemon  33) libtool  34) libunrar  35) libunrar-devel
   36) m4  37) make  38) man-db  39) pacman  40) pactoys-git  41) patch
   42) patchutils  43) perl  44) pkg-config  45) pkgfile  46) quilt  47) rcs
   48) scons  49) sed  50) swig  51) texinfo  52) texinfo-tex  53) ttyrec
   pacman -S gcc
   binutils-2.30-1  isl-0.19-1  mpc-1.1.0-1
   msys2-runtime-devel-2.11.1-2
   msys2-w32api-headers-6.0.0.5223.7f9d8753-1
   msys2-w32api-runtime-6.0.0.5223.7f9d8753-1
   windows-default-manifest-6.4-1  gcc-7.3.0-3

After installing the above the .exe files will be available in C:\msys64\usr\bin. Some of the executables that will be available are: awk, base64, curl, dd, diff, dos2unix, file, gcc, gdb, gpg, grep, gzip, head, hexdump, hostname, ld, ldd, ls, make, man, md5sum, merge, mkdir, more, mv, objdump, openssl, perl, python2, python2.7, readelf, rm, rmdir, sed, sha1sum, sha256sum, sha512sum, sort, split, stat, tail, tee, telnet, uniq, uname, vim, wget, which, whoami, yes.

There are many other executables in the C:\msys64\usr\bin directory. Keep this in mind when making the decision to add the bin directory to your Windows PATH environment variable.

References : https://www.msys2.org/ https://en.wikipedia.org/wiki/GNU_Compiler_Collection https://www.devdungeon.com/content/install-gcc-compiler-windows-msys2-cc

Clone this wiki locally