Back to posts.

Compiling x264 on Windows with MSVC

1. Download and install msys2

Go to msys2.github.io and download the 64 bit installer. On their website they have a pretty good how-to that you can follow. You select the destination and click next a couple of times. It will install all base files, but you still need to do some steps after clicking next a couple of times. Make sure you tick the [x] Run MSYS2-64 bit now. In the msys window type (also described on their website) the following command. Note that you may need to close and then open (via the windows menu) msys2 again during any of these steps. If there is no "msys2" in your start menu (which happened to me), you can execute the msys2_shell.cmd from the install directory. Next execute the following to update the packages.

$ pacman -Sy pacman
$ pacman -Syu
$ pacman -Su

2. Install dependencies

Click on the msys2_shell.cmd file from the install directory and install some more dependencies:

$ pacman -S yasm
$ pacman -S make

3. Get x264 sources

Next, because installing git with pacman in the msys shell failed, I cloned x264 using the git-bash I had installed already. So open your git-bash and clone x264.

$ cd /some/dir
$ git clone http://git.videolan.org/git/x264.git

4. Compile

Now press your windows key and type vs2015 (and of course make sure you have installed Visual Studio 2015 Express Edition), and select the VS2015 x64 Native Tools Command Prompt

Using this VS2015 x264 Native Tools Command Prompt go to your msys2 directory and type:

$ msys2_shell.cmd -mingw64 -full-path

This will open a new msys2 shell, in which the correct environment variables have been set, which allows you to compile x264 with VS2015. Now, go to your x264 directory and execute:

$ cd /to/your/x264/source
$ CC=cl ./configure --enable-static --prefix=${PWD}/installed
$ make
$ make install