Compiling Minetest 64bit on Windows
Trying to compile something like Minetest manually on Windows is about as easy as hearding cats with lasers strapped to their heads (very difficult). So today we're going to simplify the process, I'm going to borrow the work of some other people to create a buildscript you can use to create a Minetest build with LuaJIT, LuaSocket and LevelDB in one command.
Before we Start
What does this buildscript do?
It compiles Minetest 4.16 - 0.5 (tested, though will likely work outside this range) for 64bit Windows on Windows, you will need 64bit Windows (vista or greater).
Where else should I look?
The following guides were consulted in the making of my buildscript:
- Building 64-bit minetest with MSYS2/mingw64 by Fixer
- Building Minetest on Windows with LuaSocket by timcu
Installing the Required Software
Installing the software is the hardest part, which isn't to say it's hard... simply install MSYS2 from the MSYS2 website, following the instructions on the website, then go to Start > MSYS2 64bit > MSYS2 MinGW 64-bit and run the following command:
pacman -S base-devel git unzip zip mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake
This will install all of the required packages.
Setting up the Environment
All you need to do is create a folder to build in (say C:\minetest), and cd into it:
mkdir /c/minetest cd /c/minetest
Now we need the buildscript, my modified buildscript is available in this repository, but of couse you could make your own as per Fixer's instructions, I've simply included mine for convinience (there are several things you will need to change, and mine behaves slightly differently to make it only require 1 command). Download a buildscript and the latest cmake toolchain file to this directory:
wget https://raw.githubusercontent.com/minetest/minetest/master/util/buildbot/toolchain_mingw64.cmake wget https://raw.githubusercontent.com/ChimneySwift/build_win/master/buildwin64.sh
Now, get yourself a copy of Minetest:
git clone https://github.com/minetest/minetest.git
And now comes the fun part. Build it:
./buildwin64 ./minetest # replace ./minetest with the build directory of your choice
And then the script will ask you... nothing.
It will first download all of the required items, then it will compile LuaJIT and LuaSocket, and then it will compile and package your build into a neat little zip file, the directory to which will be printed at the end.
The script will attempt to bypass CMake so you don't have to recompile the entire thing every single time, if you want to force CMake to run, delete the
_build folder in your build directory.
If your command line output doesn't look similar to this, chances are something's not right and you should submit an issue on the github repo:
Chimney Swift@Swift MINGW64 /c/minetest $ ./buildwin64.sh ./minetest-master Initializing... Downloading packages... Extracting packages... Initiating build process... Building luajit... "Building LuaJIT 2.1.0-beta3" C:/msys64/mingw64/bin/mingw32-make -C src amalg mingw32-make: Entering directory 'C:/minetest/minetest-master/libs/luajit/src' +--------------------------------------------------------------------------+ | WARNING: Compiling the amalgamation needs a lot of virtual memory | | (around 300 MB with GCC 4.x)! If you don't have enough physical memory | | your machine will start swapping to disk and the compile will not finish | | within a reasonable amount of time. | | So either compile on a bigger machine or use the non-amalgamated build. | +--------------------------------------------------------------------------+ C:/msys64/mingw64/bin/mingw32-make all "LJCORE_O=ljamalg.o" mingw32-make: Entering directory 'C:/minetest/minetest-master/libs/luajit/src' mingw32-make: Nothing to be done for 'all'. mingw32-make: Leaving directory 'C:/minetest/minetest-master/libs/luajit/src' mingw32-make: Leaving directory 'C:/minetest/minetest-master/libs/luajit/src' Building luasocket... C:/msys64/mingw64/bin/mingw32-make -C src mingw mingw32-make: Entering directory 'C:/minetest/minetest-master/libs/luasocket/src' C:/msys64/mingw64/bin/mingw32-make all PLAT=mingw mingw32-make: Entering directory 'C:/minetest/minetest-master/libs/luasocket/src' mingw32-make: Nothing to be done for 'all'. mingw32-make: Leaving directory 'C:/minetest/minetest-master/libs/luasocket/src' mingw32-make: Leaving directory 'C:/minetest/minetest-master/libs/luasocket/src' ./buildwin64.sh: line 121: cd: _build: No such file or directory Attempting to compile without running CMake first (faster)... mingw32-make: *** No targets specified and no makefile found. Stop. Error running make or accessing makefile, (re)building make file... mv: cannot stat 'C:/msys64/usr/bin/sh.exe': No such file or directory -- The C compiler identification is GNU 6.2.0 -- The CXX compiler identification is GNU 6.2.0 ...snip... -- Configuring done -- Generating done -- Build files have been written to: C:/minetest/minetest-master/_build Compiling... Scanning dependencies of target GenerateVersion Scanning dependencies of target translations Scanning dependencies of target jsoncpp Scanning dependencies of target gmp [ 1%] Building CXX object lib/jsoncpp/CMakeFiles/jsoncpp.dir/jsoncpp.cpp.obj [ 1%] mo-update [uk]: Creating locale directory. [ 1%] Building C object lib/gmp/CMakeFiles/gmp.dir/mini-gmp.c.obj [ 1%] mo-update [ca]: Creating locale directory. ...snip... [100%] Building CXX object src/CMakeFiles/minetest.dir/voxelalgorithms.cpp.obj [100%] Building CXX object src/CMakeFiles/minetest.dir/wieldmesh.cpp.obj [100%] Linking CXX executable ..\..\bin\minetest.exe [100%] Built target minetest Compilation successful! Copying required DLL files to /bin... Exporting package... Deleting old package... Creating new directory and copying built Minetest... cp: cannot stat '/c/minetest/minetest-master/locale': No such file or directory cp: cannot stat '/c/minetest/minetest-master/minetest.conf': No such file or directory cp: cannot stat '/c/minetest/minetest-master/README.txt': No such file or directory Creating .zip file... All tasks finished and successful. Information: Compiled package directory: /c/minetest/minetest-master/minetest--dev Compiled zipped package location: /c/minetest/minetest-master/minetest--dev/minetest--dev.zip Minetest version: -dev