How to build VCMI (Linux/Cmake/MXE)

Contents

Compiling VCMI for Windows on Linux

Some developers may want to make Windows builds without dealing with dependencies as it may be headache when you're on Windows. It's possible to setup own cross-compiler toolkit that use MinGW, but that take time and skill. Fortunately there is project called MXE (M cross environment) that make cross compilation easy and work out of box for our engine.

Setting up a MXE cross compiler

Make sure cmake and git is installed on your system as well as all libraries and utils listed under requirements. MXE website have commands that will let install everything needed for almost every distribution.

# "settings.mk" not exist by default
# You can create it by running "make" and then aborting it by Ctrl+C
#
# Uncomment "MXE_TARGETS" and make it look like that:
MXE_TARGETS := i686-w64-mingw32.shared
# You can add this line to plugins if you want MXE to use GCC6
# This is currently break NSIS though
#override MXE_PLUGIN_DIRS += plugins/gcc6
# And you can add following packages list
LOCAL_PKG_LIST := gcc boost zlib sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf ffmpeg minizip qtbase nsis
# Make sure to uncomment two lines under the list
.DEFAULT_GOAL := local-pkg-list
local-pkg-list: $(LOCAL_PKG_LIST)

Then you can compile it:

make -j 9

Depend on your hardware that may take from 20 minutes to more than hour.

Compiling VCMI using MXE

First of all create two directories: one for CMake (vcmi-cmake) and other for result build (vcmi-build). Now build would looks like that: