Skip to content

Initial setup of MSYS2

opcodevoid edited this page Sep 3, 2016 · 3 revisions

This page documents the instructions for setting up a Windows build using MSYS2. First, you have to download and install MSYS2. Then run msys2_shell.cmd from your installation folder.

Update the package database

pacman -Sy pacman
pacman -Syu

If needed, close the MSYS2 command prompt, and run it again to update the rest.

pacman -Su

Install required tools

pacman -S yasm
pacman -S make
pacman -S autoconf automake
pacman -S diffutils
pacman -S patch
pacman -S git
pacman -S svn
pacman -S tar
pacman -S pkg-config

Building with MinGW-w64 toolchain

If you plan to create a Windows build with a mingw-msys profile, you have to install the corresponding toolchain. CMake is only required for compiling the x265 encoder.

Note that cross compiling with MSYS-MinGW will take considerably longer than cross compiling with MinGW on a Unix host.

Install 32-bit toolchain

pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-i686-libtool
pacman -S mingw-w64-i686-cmake

Install 64-bit toolchain

pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-libtool
pacman -S mingw-w64-x86_64-cmake

Building with Visual Studio toolchain

Download and install Visual Studio, preferably the newest version. As the next step, open Visual Studio (depending on what platform you target - x86 or x64) native tools command prompt. There are various ways to open it:

  • via Start Menu > Programs > Visual Studio 2015 menu folder
  • via C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\
  • or by running the corresponding batch script vc-(32|64).bat from the ffmpeg-builder\windows folder

Note that the Visual Studio version may vary from your setup. Visual Studio 2015 is the recommended version at the time of initially writing this page.

Once the native tools command prompt is opened, launch the MSYS2 shell from it by running msys2_shell.cmd which is located in your MSYS2 installation directory.

Verify your setup

Check for conflicts with MSVC

which link.exe

If you see something like /usr/bin/link.exe, then you have either to remove or rename the link binary provided by MSYS2 in order to use MSVC link.exe. To remove simply run

rm /usr/bin/link.exe

For testing purposes execute from the ffmpeg-builder directory (in this case a 64-bit version)

source profiles/msvc-15-x86_64.local

Execute the following commands to verify that all the tools below are setup properly

which link
which cl

Optionally, if you plan to compile codec libraries like opus, vorbis, x265 etc. you will require MSBuild.exe

which msbuild.exe

The paths should point to the Visual Studio installation directory and "Program Files\MSBuild".

Compiling x265

To be able to compile x265 you will additionally require CMake.

Install 32-bit version

pacman -S mingw-w64-i686-cmake

Install 64-bit version

pacman -S mingw-w64-x86_64-cmake