1Building MKVToolNix 65.0.0 for Windows 2===================================== 3 4There is currently only one supported way to build MKVToolNix for 5Windows: on Linux using a MinGW cross compiler. It is known that you 6can also build it on Windows itself with the MinGW gcc compiler, but 7that's not supported officially as I don't have such a setup myself. 8 9Earlier versions could still be built with Microsoft's Visual Studio / 10Visual C++ programs, and those steps were described here as 11well. However, current MKVToolNix versions require many features of 12the C++11 and C++14 standards which Microsoft's compilers have had 13spotty support for for a long time. Additionally the author doesn't 14use Visual C++ himself and couldn't provide project files for it. 15 16# 1. Building with a MinGW cross compiler 17 18## 1.1. Preparations 19 20You will need: 21 22- a MinGW cross compiler 23- roughly 4 GB of free space available 24 25Luckily there's the [M cross environment project](http://mxe.cc/) 26that provides an easy-to-use way of setting up the cross-compiler 27and all required libraries. 28 29MXE is a fast-changing project. In order to provide a stable basis for 30compilation, the author maintains his own fork. That fork also includes 31a couple of changes that cause libraries to be compiled only with the 32features required by MKVToolNix saving compilation time and deployment 33space. In order to retrieve that fork, you need `git`. Then do the 34following: 35 36 git clone https://gitlab.com/mbunkus/mxe $HOME/mxe 37 38The rest of this guide assumes that you've unpacked MXE 39into the directory `$HOME/mxe`. 40 41## 1.2. Automatic build script 42 43MKVToolNix contains a script that can download, compile and install 44all required libraries into the directory `$HOME/mxe`. 45 46If the script does not work or you want to do everything yourself, 47you'll find instructions for manual compilation in section 1.3. 48 49### 1.2.1. Script configuration 50 51The script is called `packaging/windows/setup_cross_compilation_env.sh`. 52It contains the following variables that can be adjusted to fit your 53needs: 54 55 ARCHITECTURE=64 56 57The architecture (64-bit vs 32-bit) that the binaries will be built 58for. The majority of users today run a 64-bit Windows, therefore 64 is 59the default. If you run a 32-bit version of Windows, change this to 32. 60 61 INSTALL_DIR=$HOME/mxe 62 63Base installation directory 64 65 PARALLEL= 66 67Number of processes to execute in parallel. Will be set to the number 68of cores available if left empty. 69 70### 1.2.2. Execution 71 72From the MKVToolNix source directory run: 73 74 ./packaging/windows/setup_cross_compilation_env.sh 75 76If everything works fine, you'll end up with a configured MKVToolNix 77source tree. You just have to run `rake` afterwards. 78 79## 1.3. Manual installation 80 81First you will need the MXE build scripts. Get them by 82downloading them (see section 1.1. above) and unpacking them into 83`$HOME/mxe`. 84 85Next, build the required libraries (change `MXE_TARGETS` to 86`i686-w64-mingw32.static` if you need a 32-bit build instead of a 64-bit 87one, and increase `JOBS` if you have more than one core): 88 89 cd $HOME/mxe 90 make MXE_TARGETS=x86_64-w64-mingw32.static MXE_PLUGIN_DIRS=plugins/gcc9 \ 91 JOBS=2 \ 92 gettext libiconv zlib boost file flac lzo ogg pthreads vorbis cmark \ 93 libdvdread qtbase qttranslations qtwinextras 94 95Append the installation directory to your `PATH` variable: 96 97 export PATH=$PATH:$HOME/mxe/usr/bin 98 hash -r 99 100Finally, configure MKVToolNix (the `host=…` spec must match the 101`MXE_TARGETS` spec from above): 102 103 cd $HOME/path/to/mkvtoolnix-source 104 host=x86_64-w64-mingw32.static 105 qtbin=$HOME/mxe/usr/${host}/qt5/bin 106 ./configure \ 107 --host=${host} \ 108 --enable-static-qt \ 109 --with-moc=${qtbin}/moc --with-uic=${qtbin}/uic --with-rcc=${qtbin}/rcc \ 110 --with-boost=$HOME/mxe/usr/${host} 111 112If everything works, build it: 113 114 rake 115 116You're done. 117