OpenXcom Forum

Modding => OpenXcom Extended => Topic started by: Meridian on March 24, 2019, 07:56:15 pm

Title: [4] Compiling and cross-compiling OXCE
Post by: Meridian on March 24, 2019, 07:56:15 pm
Applies to all builds and all platforms:
- don't use yaml-cpp 0.7.x, it's broken
- if you can, use yaml-cpp 0.6.3




1. Building on Windows using Visual Studio 2022 (Win32 build only)

1. Download, install and update Visual Studio 2022 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 (https://drive.google.com/open?id=1p6YTnfv0FJyHuPtzRuhir5-00cN84xBB)
4. Open solution "src/OpenXcom.2010.sln"
5. Click "Build" from menu or toolbar

PS: in Visual Studio 2022 v17.2+ you'll need this workaround, until VS is fixed: https://github.com/723Studio/OpenXcom_FTA/commit/bcc4d5e14340d3fbf9a920d0c87fb88a51399867
Title: Re: [4] Compiling and cross-compiling OXCE
Post by: Meridian on March 28, 2019, 03:50:14 pm
2. Building on Linux (tested on Kubuntu 18.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.
Title: Re: [4] Compiling and cross-compiling OXCE
Post by: Meridian on March 28, 2019, 03:50:35 pm
3. Building OXCE from source on Mac (tested on macOS 10.15 Catalina)

macOS 11 Big Sur seems not compatible with SDL1.2, thus cannot run OpenXcom nor OXCE

macOS 12 Monterey seems to be working again? to be investigated... More info: https://openxcom.org/forum/index.php/topic,6596.msg145012.html#msg145012

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

3.1 Install tools and dependencies via brew:

For recent versions (macOS 10.13+)

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. macOS 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 macOS 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 macOS 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 macOS 10.9 here: MacOSX10.9.sdk.zip (https://drive.google.com/open?id=17pUKRyknkKoWDUhwrsN6Qi6AqiREhG1X)
I recommend placing it into /Developer/SDKs/MacOSX10.9.sdk
EDIT: macOS 10.15 (Catalina) will probably not allow you to place the SDK there... just put it anywhere it allows you and change the cmake command accordingly

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
Title: Re: [4] Compiling and cross-compiling OXCE
Post by: Meridian 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"
Title: Re: [4] Compiling and cross-compiling OXCE
Post by: Meridian on March 28, 2019, 03:51:27 pm
5. Compilation for Android

See readme at: https://github.com/MeridianOXC/openxcom-android
Title: Re: [4] Compiling and cross-compiling OXCE
Post by: Meridian on March 28, 2019, 03:51:41 pm
6. Compilation for iOS

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