Difference between revisions of "How to build VCMI (Linux/Cmake/MXE)"

From VCMI Project Wiki
Jump to: navigation, search
(Basic contents)
 
(Compiling VCMI using MXE)
Line 18: Line 18:
 
= Compiling VCMI using MXE =
 
= 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:
 
First of all create two directories: one for CMake (vcmi-cmake) and other for result build (vcmi-build). Now build would looks like that:
<pre>git clone https://github.com/vcmi/vcmi.git
+
<pre># Clone VCMI repository
# To build without launcher:
+
git clone https://github.com/vcmi/vcmi.git
cmake ../vcmi -DCMAKE_TOOLCHAIN_FILE=/home/test/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake -DCMAKE_INSTALL_PREFIX=/home/test/vcmi-build -DENABLE_LAUNCHER=0
 
# With launcher:
 
cmake ../vcmi -DCMAKE_TOOLCHAIN_FILE=/home/test/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake -DCMAKE_INSTALL_PREFIX=/home/test/vcmi-build
 
  
make -j 9</pre>
+
# Go into your CMake directory
Now you can see build
+
cd vcmi-cmake
 +
 
 +
# To build with launcher:
 +
cmake ../vcmi \
 +
-DCMAKE_TOOLCHAIN_FILE=/home/test/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake \
 +
-DCMAKE_INSTALL_PREFIX=/home/test/vcmi-build
 +
 
 +
# Without launcher:
 +
cmake ../vcmi -DCMAKE_TOOLCHAIN_FILE=/home/test/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake \
 +
-DCMAKE_INSTALL_PREFIX=/home/test/vcmi-build \
 +
-DENABLE_LAUNCHER=0
 +
 
 +
# Compile
 +
make -j 9
 +
 
 +
# Move binaries into target directory
 +
make install</pre>

Revision as of 11:54, 26 January 2016

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 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.

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.

Once it done clone MXE using git. Then you need to edit "settings.mk" file:

# Uncomment "MXE_TARGETS" and make it look like that:
MXE_TARGETS := i686-w64-mingw32.shared

Then you can compile it:

make -j 9 gcc boost zlib sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf ffmpeg qt5

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

Removing "Qt 5" that only used for launcher will drastically reduce compile time:

make -j 9 gcc boost zlib sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_ttf ffmpeg

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:

# Clone VCMI repository
git clone https://github.com/vcmi/vcmi.git

# Go into your CMake directory
cd vcmi-cmake

# To build with launcher:
cmake ../vcmi \
-DCMAKE_TOOLCHAIN_FILE=/home/test/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake \
-DCMAKE_INSTALL_PREFIX=/home/test/vcmi-build

# Without launcher:
cmake ../vcmi -DCMAKE_TOOLCHAIN_FILE=/home/test/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake \
-DCMAKE_INSTALL_PREFIX=/home/test/vcmi-build \
-DENABLE_LAUNCHER=0

# Compile
make -j 9

# Move binaries into target directory
make install