Difference between revisions of "Compiling (OpenApoc)"

From UFOpaedia
Jump to navigation Jump to search
(Created page with "== Building == OpenApocalypse is built leveraging a number of libraries - to provide needed functionality (and save us the time of implementing it ourselves badly) * [http:/...")
 
(Update for Cmake)
(2 intermediate revisions by the same user not shown)
Line 12: Line 12:
 
* [http://libsmacker.sourceforge.net/ libsmacker] - Decoder for .smk video files.
 
* [http://libsmacker.sourceforge.net/ libsmacker] - Decoder for .smk video files.
 
* [http://lodev.org/lodepng/ lodepng] - Reading/writing PNG image files.
 
* [http://lodev.org/lodepng/ lodepng] - Reading/writing PNG image files.
 +
* [https://www.lua.org/ Lua] - Scripting language.
 
* [https://github.com/richgel999/miniz miniz] - Zlib-comptible compression library.
 
* [https://github.com/richgel999/miniz miniz] - Zlib-comptible compression library.
 
* [https://icculus.org/physfs/ physfs] - Library for reading data from .iso files or directory trees (Note: We use a patched version, available on [https://github.com/JonnyH/physfs-hg-import/tree/fix-iso) - required to read the .iso files we use GitHub].
 
* [https://icculus.org/physfs/ physfs] - Library for reading data from .iso files or directory trees (Note: We use a patched version, available on [https://github.com/JonnyH/physfs-hg-import/tree/fix-iso) - required to read the .iso files we use GitHub].
Line 20: Line 21:
  
 
# Checkout OpenApoc from GitHub.
 
# Checkout OpenApoc from GitHub.
# If you are using the GitHub client for Windows, the submodules should already be setup at first checkout. If not using the github client, or if the submodules have been updated, run the following commands in the 'git shell' from the root of the OpenApoc repository. This should reset the submodule checkouts to the latest versions (NOTE: This will overwrite any changes to code in the dependencies/ directory).
+
# If you are using the GitHub client for Windows, the submodules should already be setup at first checkout. If not using the github client, or if the submodules have been updated, run the following commands in the 'git shell' from the root of the OpenApoc repository. This should reset the submodule checkouts to the latest versions (NOTE: This will overwrite any changes to code in the dependencies/ directory). <pre>git submodule update --init --recursive</pre>
 
+
# All the other dependencies (Boost, SDL2) need to be supplied separately. Install [https://github.com/Microsoft/vcpkg Vcpkg] and run the following command: <pre>vcpkg install sdl2 boost-locale boost-system boost-program-options boost-filesystem boost-uuid boost-crc</pre>
<nowiki>cmd
 
git submodule init
 
git submodule update -f</nowiki>
 
 
 
# All the other dependencies (Boost, SDL2) are provided automatically by nuget packages, and Visual Studio should automatically download and install these at the first build.
 
 
# Copy the original XCom:Apocalypse .iso file into the "data/" directory. This could also be a directory containing all the extracted files from the CD, and it should be named the same (IE the directory should be data/cd.iso/). This is used during the build to extract some data tables.
 
# Copy the original XCom:Apocalypse .iso file into the "data/" directory. This could also be a directory containing all the extracted files from the CD, and it should be named the same (IE the directory should be data/cd.iso/). This is used during the build to extract some data tables.
# Open openapoc.sln in Visual Studio.
+
# Open the Git directory in Visual Studio (if you don't have an Open Folder option, generate a project from CMake).
# Build (Release/Debug x86/x64 should all work).
+
# Visual Studio should automatically detect and configure CMake appropriately. To add your Vcpkg dependencies, edit your CMake Settings file and add: <pre>"variables": [&#10;    {&#10;        "name": "CMAKE_TOOLCHAIN_FILE",&#10;        "value": "<path to vcpkg>\\scripts\\buildsystems\\vcpkg.cmake"&#10;    }&#10;]</pre>
 +
# If you get errors, clear your cache from the CMake menu and generate again.
 +
# Build (Release/Debug x86/x64 should all work). Release is recommended as Debug is very slow.
 
# When running from the Visual Studio UI, the working directory is set to the root of the project, so the data folder should already be in the right place. If you want to run outside of Visual Studio, you need to copy the whole 'data' folder (including the cd.iso file) into the folder openapoc.exe resides in.
 
# When running from the Visual Studio UI, the working directory is set to the root of the project, so the data folder should already be in the right place. If you want to run outside of Visual Studio, you need to copy the whole 'data' folder (including the cd.iso file) into the folder openapoc.exe resides in.
  
Line 36: Line 34:
 
(Tested on Ubuntu 16.04)
 
(Tested on Ubuntu 16.04)
  
# Install the following packages:
+
# Install the following packages: <pre>sudo apt-get install libsdl2-dev cmake build-essential git libunwind8-dev libboost-locale-dev libboost-filesystem-dev libboost-system-dev libboost-program-options-dev</pre>
 
 
<nowiki>sh
 
sudo apt-get install libsdl2-dev cmake build-essential git libunwind8-dev libboost-locale-dev libboost-filesystem-dev libboost-system-dev libboost-program-options-dev</nowiki>
 
 
 
 
# Checkout OpenApoc from GitHub.
 
# Checkout OpenApoc from GitHub.
# Fetch the dependencies from git with the following terminal command (run from the just-created OpenApoc folder).
+
# Fetch the dependencies from git with the following terminal command (run from the just-created OpenApoc folder). <pre>git submodule update --init --recursive</pre>
 
+
# Copy the cd.iso file to the 'data' directory under the repository root (Note - despite dosbox having good linux support, the steam version of X-Com Apocalypse will only install if Steam Play is enabled). <pre>cp /path/to/cd.iso data/</pre>
<nowiki>sh
+
# Create a subdirectory ('build' in this example) in the OpenApoc checkout directory, and from that use cmake to configure OpenApoc. <pre>cd /path/to/OpenApoc&#10;mkdir build&#10;cd build&#10;cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..</pre>
git submodule init
 
git submodule update</nowiki>
 
 
 
# Copy the cd.iso file to the 'data' directory under the repository root (Note - despite dosbox having good linux support, the steam version of X-Com Apocalypse refuses to install in steam for linux - you may need to snatch the cd.iso file off a windows steam install).
 
 
 
<nowiki>sh
 
cp /path/to/cd.iso data/</nowiki>
 
 
 
# Create a subdirectory ('build' in this example) in the OpenApoc checkout directory, and from that use cmake to configure OpenApoc.
 
 
 
<nowiki>sh
 
cd /path/to/OpenApoc
 
mkdir build
 
cd build
 
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..</nowiki>
 
 
 
 
# This cmake command will fail if we're missing a dependency, or your system is for some other reason unable to build - if you have any issues please contact us (see above for links).
 
# This cmake command will fail if we're missing a dependency, or your system is for some other reason unable to build - if you have any issues please contact us (see above for links).
# Build the project with the following command.
+
# Build the project with the following command. <pre>make -j4</pre>
 
+
# This should create a directory 'bin' under the build directory, with the 'OpenApoc' executable file. OpenApoc by default expects the data folder to be in the current working directory, so running the executable from the root of the git checkout should work. <pre>./build/bin/OpenApoc</pre>
<nowiki>sh
 
make -j4</nowiki>
 
 
 
# This should create a directory 'bin' under the build directory, with the 'OpenApoc' executable file. OpenApoc by default expects the data folder to be in the current working directory, so running the executable from the root of the git checkout should work.
 
  
<nowiki>sh
+
[[Category:OpenApoc]]
./build/bin/OpenApoc</nowiki>
 

Revision as of 23:17, 11 March 2019

Building

OpenApocalypse is built leveraging a number of libraries - to provide needed functionality (and save us the time of implementing it ourselves badly)

  • SDL2
  • Boost - specifially the 'locale' library, used for localisation, 'program-options' for settings management, and 'filesystem'.
  • Libunwind - debug backtracing on linux - not needed on windows.

The following libraries are also used, but are shipped as submodules in the repository and directly included in the build, so you don't need to install these dependencies to build or use openapoc.

Windows

  1. Checkout OpenApoc from GitHub.
  2. If you are using the GitHub client for Windows, the submodules should already be setup at first checkout. If not using the github client, or if the submodules have been updated, run the following commands in the 'git shell' from the root of the OpenApoc repository. This should reset the submodule checkouts to the latest versions (NOTE: This will overwrite any changes to code in the dependencies/ directory).
    git submodule update --init --recursive
  3. All the other dependencies (Boost, SDL2) need to be supplied separately. Install Vcpkg and run the following command:
    vcpkg install sdl2 boost-locale boost-system boost-program-options boost-filesystem boost-uuid boost-crc
  4. Copy the original XCom:Apocalypse .iso file into the "data/" directory. This could also be a directory containing all the extracted files from the CD, and it should be named the same (IE the directory should be data/cd.iso/). This is used during the build to extract some data tables.
  5. Open the Git directory in Visual Studio (if you don't have an Open Folder option, generate a project from CMake).
  6. Visual Studio should automatically detect and configure CMake appropriately. To add your Vcpkg dependencies, edit your CMake Settings file and add:
    "variables": [
        {
            "name": "CMAKE_TOOLCHAIN_FILE",
            "value": "<path to vcpkg>\\scripts\\buildsystems\\vcpkg.cmake"
        }
    ]
  7. If you get errors, clear your cache from the CMake menu and generate again.
  8. Build (Release/Debug x86/x64 should all work). Release is recommended as Debug is very slow.
  9. When running from the Visual Studio UI, the working directory is set to the root of the project, so the data folder should already be in the right place. If you want to run outside of Visual Studio, you need to copy the whole 'data' folder (including the cd.iso file) into the folder openapoc.exe resides in.

Linux

(Tested on Ubuntu 16.04)

  1. Install the following packages:
    sudo apt-get install libsdl2-dev cmake build-essential git libunwind8-dev libboost-locale-dev libboost-filesystem-dev libboost-system-dev libboost-program-options-dev
  2. Checkout OpenApoc from GitHub.
  3. Fetch the dependencies from git with the following terminal command (run from the just-created OpenApoc folder).
    git submodule update --init --recursive
  4. Copy the cd.iso file to the 'data' directory under the repository root (Note - despite dosbox having good linux support, the steam version of X-Com Apocalypse will only install if Steam Play is enabled).
    cp /path/to/cd.iso data/
  5. Create a subdirectory ('build' in this example) in the OpenApoc checkout directory, and from that use cmake to configure OpenApoc.
    cd /path/to/OpenApoc
    mkdir build
    cd build
    cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
  6. This cmake command will fail if we're missing a dependency, or your system is for some other reason unable to build - if you have any issues please contact us (see above for links).
  7. Build the project with the following command.
    make -j4
  8. This should create a directory 'bin' under the build directory, with the 'OpenApoc' executable file. OpenApoc by default expects the data folder to be in the current working directory, so running the executable from the root of the git checkout should work.
    ./build/bin/OpenApoc