Author Topic: [4] Compiling and cross-compiling OXCE  (Read 1147 times)

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 4959
  • Aaand we're back!
    • View Profile
    • My Wiki
[4] Compiling and cross-compiling OXCE
« on: March 24, 2019, 07:56:15 pm »
1. Building on Windows using Visual Studio 2017/2019

1. Download, install and update Visual Studio 2019 Community Edition: https://visualstudio.microsoft.com/downloads/
2. Clone OXCE repo: https://github.com/MeridianOXC/OpenXcom.git
3. Download and extract the pre-compiled dependencies (into repo's root): openxcom-deps-win-vc2017-newest.zip
4. Open solution "src/OpenXcom.2010.sln"
5. Click "Build" from menu or toolbar
« Last Edit: April 24, 2019, 02:08:31 pm by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 4959
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: [4] Compiling and cross-compiling OXCE
« Reply #1 on: March 28, 2019, 03:50:14 pm »
2. Building on Linux (tested on Kubuntu 16.04)

2.1 First, you need git, cmake, build essentials (compiler, etc.) and SDL libraries.

Code: [Select]
apt install git cmake build-essential libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-gfx1.2-dev zlib1g-dev

And also a recent version of yaml-cpp library:

Code: [Select]
git clone https://github.com/jbeder/yaml-cpp
cd yaml-cpp
mkdir yaml-build
cd yaml-build
cmake .. -DCMAKE_BUILD_TYPE=Release -DYAML_CPP_BUILD_CONTRIB=OFF -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOOLS=OFF
sudo make install

This will install it into /usr/local, so you'll need privileges for that.

2.2 Now OXCE itself

Code: [Select]
git clone https://github.com/MeridianOXC/OpenXcom.git
cd OpenXcom
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DDEV_BUILD=OFF -DBUILD_PACKAGE=OFF
make -j4

You will end up with build/bin directory with the executable and the resources.

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 4959
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: [4] Compiling and cross-compiling OXCE
« Reply #2 on: March 28, 2019, 03:50:35 pm »
3. Building OXCE from source on Mac (tested on Mac OS X 10.13 and 10.14)

Install brew, see: https://brew.sh/

3.1 Install tools and dependencies via brew:

For recent versions (e.g. Mac OS X 10.13 or 10.14)

Code: [Select]
brew install git cmake zip yaml-cpp --with-static-lib sdl sdl_gfx sdl_image sdl_mixer --with-flac --with-libmikmod --with-libvorbis --with-static-lib

For older versions (e.g. Mac OS X 10.9), you may need a simpler command:

Code: [Select]
brew install git cmake zip sdl sdl_gfx sdl_image sdl_mixer yaml-cpp

3.2 Now OXCE itself

On Mac OS X 10.13 or earlier:

Code: [Select]
git clone https://github.com/MeridianOXC/OpenXcom.git
cd OpenXcom
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE="Release"
make -j4

Starting with Mac OS X 10.14 (Mojave), there are issues with OpenGL, which is not supported by Apple anymore.
The compilation works, but the game doesn't.
Therefore, you will need an earlier version of the SDK and instruct cmake to lower the deployment target.
You can download SDK for Mac OS X 10.9 here: MacOSX10.9.sdk.zip
I recommend placing it into /Developer/SDKs/MacOSX10.9.sdk

Updated cmake command:

Code: [Select]
cmake .. -DCMAKE_BUILD_TYPE="Release" -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.9.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9

You will end up with build/openxcom.app bundle.
A .dmg is made out of it using:

Code: [Select]
make package
« Last Edit: March 28, 2019, 03:55:25 pm by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 4959
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: [4] Compiling and cross-compiling OXCE
« Reply #3 on: March 28, 2019, 03:51:13 pm »
4. Cross-compiling OXCE for Windows 32/64bit on Linux (tested on Kubuntu 18.04)

4.1 First you need git, zip and mxe.

Code: [Select]
apt install git zip

Clone the mxe environment somewhere, for example in /opt/mxe:

Code: [Select]
cd /opt
sudo git clone https://github.com/mxe/mxe.git
sudo chown -R `whoami`: mxe

Check/install the mxe requirements: https://mxe.cc/#requirements

Set up mxe:

Code: [Select]
cd /opt/mxe
make MXE_PLUGIN_DIRS=plugins/gcc8 MXE_TARGETS=x86_64-w64-mingw32.static JOBS=8 gcc cmake sdl sdl_gfx sdl_mixer sdl_image yaml-cpp zlib

4.2 Clone the OpenXcom repo (for example in your home dir), make a build dir and build.

Code: [Select]
git clone https://github.com/MeridianOXC/OpenXcom.git
cd OpenXcom
mkdir build
cd build
export PATH=/opt/mxe/usr/bin:$PATH
/opt/mxe/usr/bin/x86_64-w64-mingw32.static-cmake -DCMAKE_BUILD_TYPE=Release -DDEV_BUILD=OFF -DBUILD_PACKAGE=OFF ..
make -j4

You will end up with build/bin directory with the executable ("libopenxcom.dll.a" can be safely ignored) and the resources.
Optionally you can make the exe smaller by running:

Code: [Select]
cd bin
/opt/mxe/usr/bin/x86_64-w64-mingw32.static-strip -d openxcom.exe

PS: to make a 32bit build use "i686-w64-mingw32" instead of "x86_64-w64-mingw32"

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 4959
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: [4] Compiling and cross-compiling OXCE
« Reply #4 on: March 28, 2019, 03:51:27 pm »
5. Compilation for Android

See readme at: https://github.com/MeridianOXC/openxcom-android

Offline Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 4959
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: [4] Compiling and cross-compiling OXCE
« Reply #5 on: March 28, 2019, 03:51:41 pm »
6. Compilation for iOS

See readme at: https://github.com/MeridianOXC/openxcom-ios