< All posts

March 5, 2021, 2:38 p.m.

Compiling Minetest on Windows

The latest Minetest 5.4.0 was released last February 23, 2021. The binary can be downloaded at the official Minetest website at https://www.minetest.net/downloads/. But if you want to impress your friends that you can compile Minetest from the source code, follow this guide :D

We need to do the following:

  1. Install Pre-requisite for compiling Minetest
  2. Get the 5.4.0 source code on the Minetest Github
  3. Compile Minetest
  4. Play Minetest

Installing Pre-requisite for compiling Minetest

We need to have Microsoft Visual Studio 2015 or higher, cmake, vcpkg and git for windows.
I won’t cover the installation of Visual Studio or Git for Windows in this guide. You can get the git for windows at this site: https://gitforwindows.org/.

After installing git for windows, we now need to install of vcpkg:

Create a folder at C:\src\ and right click, select Open GIT Bash/CLI here. You should now be at the C:\src\ directory:

$ git clone https://github.com/microsoft/vcpkg
$ .\vcpkg\bootstrap-vcpkg.bat --disableMetrics

The parameter --disableMetrics will disallow vcpkg from phoning home to Micro$oft.

minetest_vcpkg_01.png

Installing the required and optional packages to build Minetest:

> vcpkg install irrlicht zlib curl[winssl] openal-soft libvorbis libogg sqlite3 freetype luajit gmp jsoncpp --triplet x86-windows
> vcpkg install irrlicht zlib curl[winssl] openal-soft libvorbis libogg sqlite3 freetype luajit gmp jsoncpp --triplet x64-windows

This ate about 3 GB of disk space.

minetest_vcpkg_02.png

Getting the Minetest 5.4.0 Source Code

The official Minetest git repository can be found at: https://github.com/minetest/minetest. I just grabbed a compressed source code at the Releases page: https://github.com/minetest/minetest/archive/5.4.0.zip. Extract the zip file with 7-zip or your favourite application for decompressing zip.

Alternatively you can git clone the stable-5 branch, Open Git Bash/CLI:

$ git clone --branch stable-5 https://github.com/minetest/minetest

Cloning into 'minetest'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 71127 (delta 8), reused 10 (delta 4), pack-reused 71102
Receiving objects: 100% (71127/71127), 77.69 MiB | 1.20 MiB/s, done.
Resolving deltas: 100% (51145/51145), done.

Compiling Minetest using CMAKE GUI and vcpkg toolchain

1 . Open the CMAKE GUI at C:\src\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake-gui.exe

minetest_cmake_selectsrc_03.png

2 . Select Browse Source... and select the directory that contains the minetest source code, eg. DIR/minetest.

3 . Select Browse Build... and select the directory that contains the minetest source code build directory, eg.DIR/minetest-build.

4 . Click Configure.

5 . Choose the visual Studio version that is currently installed and target platform (either x86 or x64 [default]). It needs to match the version of the installed dependencies.

6 . Choose Specify toolchain file for cross-compiling.

minetest_cmake_config_set_04.png

7 . Click Next.

8 . Select the vcpkg toolchain file e.g. C:\vcpkg\scripts\buildsystems\vcpkg.cmake.

minetest_cmake_configsel_toolchain_05.png

9 . Click Finish.

10 . Wait until cmake have generated the build files.

minetest_cmake_config_06.png

11 . If there are any errors, solve them and hit Configure.

12 . Click Generate.

minetest_cmake_generate_done_07.png

13 . Click Open Project, Visual Studio should launch.

minetest_cmake_openvs_08.png

14 . Select target BUILD to Release on Visual Studio and click BUILD > BUILD ALL.

minetest_vs_config_build_09.png

15 . Wait for it to build (mine took around 18 minutes).

minetest_vs_building_10.png

minetest_vs_done_11.png

16 . After the build, copy the bin/Releases contents to bin and click Build > Clean ALL_BUILD to clean solution and free up around a gigabyte of disk space.

Playing Minetest

Run bin\minetest.exe

Note: The compiled Minetest does not contain the Minetest Game, it is only an engine.

References:

https://github.com/minetest/minetest#compile-minetest

Except where otherwise noted, this work is licensed under Creative Commons Attribution-ShareAlike 4.0 International License (http://creativecommons.org/licenses/by-sa/4.0/).