This thing’s primary use is to build Windows binaries of mpv.
Alternatively, you can download the builds from here.
-
You should also install Ninja and use CMake’s Ninja build file generator. It’s not only much faster than GNU Make, but also far less error-prone, which is important for this project because CMake’s ExternalProject module tends to generate makefiles which confuse GNU Make’s jobserver thingy.
-
As a build environment, any modern Linux distribution should work.
-
Compiling on Cygwin / MSYS2 is supported, but it tends to be slower than compiling on Linux.
-
Git/Hg
- FFmpeg
- xz
- x264
- x265 (multilib)
- uchardet
- rubberband
- opus
- openal-soft
- mpv
- luajit
- libvpx
- libwebp
- libpng
- libudfread
- libunibreak
- libass
- lcms2
- lame
- harfbuzz
- freetype2
- flac
- opus-tools
- mujs
- libjpeg
- shaderc (with spirv-headers, spirv-tools, glslang)
- vulkan-header
- vulkan
- spirv-cross
- fribidi
- curl
- libxml2
- nvcodec-headers
- aom
- dav1d
- libplacebo (with glad)
- fontconfig
- libsrt
- libdovi
- libva
-
Zip
- expat (2.5.0)
- bzip (1.0.8)
- zlib (1.2.13)
- vorbis (1.3.7)
- ogg (1.3.5)
- lzo (2.10)
- libopenmpt (0.6.7)
- libiconv (1.17)
- gmp (6.2.1)
- libsdl2 (2.26.2)
- mbedtls (3.3.0)
libressl (3.1.5)
These packages need to be installed first before compiling mpv:
pacman -S git gyp mercurial subversion ninja cmake meson ragel yasm nasm asciidoc enca gperf unzip p7zip gcc-multilib clang python-pip curl lib32-glib2
pip3 install rst2pdf mako jsonschema
apt-get install build-essential checkinstall bison flex gettext git mercurial subversion ninja-build gyp cmake yasm nasm automake pkgconf libtool libtool-bin gcc-multilib g++-multilib clang libgmp-dev libmpfr-dev libmpc-dev libgcrypt-dev gperf ragel texinfo autopoint re2c asciidoc python3-pip docbook2x unzip p7zip-full curl
pip3 install rst2pdf meson mako jsonschema
Note:
- Use apt-fast if apt-get is too slow.
- It is advised to use bash over dash. Set
sudo ln -sf /bin/bash /bin/sh
. Revert back bysudo ln -sf /bin/dash /bin/sh
. - On WSL platform, compiling 32bit requires qemu. Refer to this.
- To update package installed by pip, run
pip3 install <package> --upgrade
.
Download Cygwin installer and run:
setup-x86_64.exe -R "C:\cygwin64" -q --packages="bash,binutils,bzip2,cygwin,gcc-core,gcc-g++,cygwin32-gcc-core,cygwin32-gcc-g++,gzip,m4,pkgconf,make,unzip,zip,diffutils,wget,git,patch,cmake,gperf,yasm,enca,asciidoc,bison,flex,gettext-devel,mercurial,python-devel,python-docutils,docbook2X,texinfo,libmpfr-devel,libgmp-devel,libmpc-devel,libtool,autoconf2.5,automake,automake1.9,libxml2-devel,libxslt-devel,meson,libunistring5"
Additionally, some packages, re2c
, ninja
, ragel
, gyp
, rst2pdf
, nasm
need to be installed manually.
Install MSYS2 and run it via MSYS2 MSYS
shortcut.
Don't use MSYS2 MinGW 32-bit
or MSYS2 MinGW 64-bit
shortcuts, that's important!
These packages need to be installed first before compiling mpv:
pacman -S base-devel cmake gcc yasm nasm git mercurial subversion gyp tar gmp-devel mpc-devel mpfr-devel python zlib-devel unzip zip p7zip meson libunistring5
Don't install anything from the mingw32
and mingw64
repositories,
it's better to completely disable them in /etc/pacman.conf
just to be safe.
Additionally, some packages, re2c
, ninja
, ragel
, libjpeg
, rst2pdf
, jinja2
need to be installed manually.
To set up the build environment, create a directory to store build files in:
mkdir build64
cd build64
Once you’ve changed into that directory, run CMake, e.g.
cmake -DTARGET_ARCH=x86_64-w64-mingw32 -G Ninja ..
add -DGCC_ARCH=x86-64-v3
to command-line if you want to compile gcc with new x86-64-v3
instructions. Other value like native
, znver3
should work too in theory.
or for 32bit:
cmake -DTARGET_ARCH=i686-w64-mingw32 -G Ninja ..
First, you need to build toolchain. By default, it will be installed in install
folder. This take ~20 minutes on my 4-core machine.
ninja gcc
After it done, you're ready to build mpv and all its dependencies:
ninja mpv
This will take a while (about ~10 minutes on my machine).
On WSL2, you might see it stuck with 100% disk usage and never finished. To fix it, build package shaderc
, spirv-cross
and harfbuzz
separately first before mpv
.
The final build64
folder's size will be around ~3GB.
To build mpv for a second time:
ninja update
After that, build mpv as usual:
ninja mpv
This will also build all packages that mpv
depends on.
Commands | Description |
---|---|
ninja package | compile a package |
ninja clean | remove all stamp files in all packages. |
ninja download | Download all packages' sources at once without compiling. |
ninja update | Update all git repos. When a package pulls new changes, all of its stamp files will be deleted and will be forced rebuild. If there is no change, it will not remove the stamp files and no rebuild occur. Use this instead of ninja clean if you don't want to rebuild everything in the next run. |
ninja package-fullclean | Remove all stamp files of a package. |
ninja package-liteclean | Remove build, clean stamp files only. This will skip re-configure in the next running ninja package (after the first compile). Updating repo or patching need to do manually. Ideally, all DEPENDS targets in package.cmake should be temporarily commented or deleted. Might be useful in some cases. |
ninja package-removebuild | Remove 'build' directory of a package. |
ninja package-removeprefix | Remove 'prefix' directory. |
ninja package-force-update | Update a package. Only git repo will be updated. |
package
is package's name found in packages
folder.
This project was originally created and maintained lachs0r. Since then, it heavily modified to suit my own need.