Skip to content

Building on Linux or xBSD

Vitaly Novichkov edited this page Jun 12, 2022 · 14 revisions
Clone this wiki locally

The game should work with GCC, Clang, or IntelCC on your choice. A compiler must support the C++11 standard.

After you will install compiler toolchains, CMake, GIT, and (optionally) a ninja-build, you can run the build!

Dependencies

Until you will get the ability to build the game, there are next dependencies you will need to install:

Ubuntu / Debian / Mint

sudo apt-get install gcc g++ git cmake ninja-build libsdl2-dev libpng-dev libjpeg-dev

RedHat 8+ / CentOS 8+ / Fedora

sudo dnf install gcc gcc-c++ git cmake ninja-build SDL2-devel libpng-devel openjpeg-devel alsa-lib-devel

CentOS 7

sudo yum install gcc gcc-c++ git cmake ninja-build SDL2-devel libpng-devel openjpeg-devel alsa-lib-devel

Building

  1. Clone repository:

    git clone https://github.com/Wohlstand/TheXTech.git
  2. Make sure all submodules were pulled, otherwise, it won't build:

    cd TheXTech
    git submodule init
    git submodule update
  3. Make the building directory:

    mkdir build
    cd build
  4. Run a CMake configuring:

    For the local debugging

    # when you want to use the regular GNU Make
    cmake -DCMAKE_BUILD_TYPE=Debug ..
    # OR when you want to use Ninja which does better parallel processes management
    cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ..

    To produce the release build you plan to share with others

    cmake -G Ninja \
        -DCMAKE_BUILD_TYPE=MinSizeRel \
        -DUSE_SYSTEM_SDL2=OFF \
        -DUSE_SYSTEM_LIBS=OFF \
        -DUSE_STATIC_LIBC=ON \
        -DPGE_SHARED_SDLMIXER=OFF \
    ..

    A note for ppc64xx builds: Please add the -DUSE_FREEIMAGE_SYSTEM_LIBS=ON flag to use PNG and JPEG libraries from the system if the project gets unbuildable.

  5. Run the build itself:

    # Run regular GNU Make build with 4 parallel tasks (suggested on 4-core CPU, if you have more cores, use a different number than 4)
    make -j 4
    # Or run a Ninja build
    ninja

Running and debugging a build

The built game will not work until you will prepare the game root. Please prepare the game root until you will be able to run a game. The game root by default is located in your home directory and you can have multiple builds with different configurations and modes, all will use the same game root directory at your home directory.

  1. Make a folder in your home directory:
mkdir -p ~/.PGE_Project/thextech/
  1. Download one of two archives with compatible assets:
  2. Unpack the content of the archive into your ~/.PGE_Project/thextech/ directory
  3. Make in the ~/.PGE_Project/thextech/ directory the "worlds" folder and put any compatible episodes you have (all episodes made for an original SMBX 1.3 and earlier will work here). Optionally you can make the "battle" folder and put a bunch of level fils which will be used for battle arena purposes.
  4. Once your game root directory is ready, feel free to run the output/bin/thextech binary (or the "Run"/"Debug" button at your IDE) to start a game.

Packages creation

You can produce the game build that will be suitable for installable packages if you follow the next conditions:

  • Suggested to use the system-wide installed SDL2 -DUSE_SYSTEM_SDL2=ON. Use the vendored SDL2 version once a system-wide version is too old (the minimal SDL2 version supported is 2.0.8)
  • Disable the shared mode of MixerX using the -DPGE_SHARED_SDLMIXER=OFF flag.
  • Make usage of system-wide libPNG and libJPEG: -DUSE_FREEIMAGE_SYSTEM_LIBS=ON.
  • Customize the executable name using -DTHEXTECH_EXECUTABLE_NAME="gamename" to avoid the possible name collision when installing multiple games built on the same engine.
  • Specify the default path where assets package (read-only) will be installed: -DTHEXTECH_FIXED_ASSETS_PATH=/usr/share/games/gamename
  • Specify the name of the user directory that will be created at the user's home directory where are settings, game saves, taken screenshots and GIF recordings, logs, and user-provided episodes and battle levels: -DTHEXTECH_USER_DIR_NAME=.my-game-name
  • When building the package, download one of the existing game assets packages or provide your own modification you do have. All content of the assets archive should be installed into the directory specified at the THEXTECH_FIXED_ASSETS_PATH argument.

Troubleshooting:

  • On ArchLinux, please avoid using the -Wformat and -Wformat-security arguments as they break the libFfeeImage build.

DEB example

Here is a little script example on how to make the DEB package on Ubuntu 20.04 for amd64 architecture:

# Create a build directory
mkdir build-deb
cd build-deb

# Configure the build
cmake \
    -G Ninja \
    -DPGE_SHARED_SDLMIXER=OFF \
    -DUSE_SYSTEM_SDL2=ON \
    -DUSE_FREEIMAGE_SYSTEM_LIBS=ON \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=MinSizeRel \
    -DTHEXTECH_FIXED_ASSETS_PATH=/usr/share/games/smbx \
    -DTHEXTECH_SOURCE_ASSETS_PATH="/full/path/to/unpacket/assets/thextech-smbx13-assets-full" \
    -DTHEXTECH_USER_DIR_NAME=".thextech-smbx" \
    -DDESKTOP_NAME="Super Mario Bros. X" \
    -DDESKTOP_GENERIC_NAME="Super Mario Bros. X" \
    -DDESKTOP_COMMENT="The Mario fan game" \
    -DTHEXTECH_EXECUTABLE_NAME="thextech-smbx" \
    -DTHEXTECH_PACKAGE_NAME="thextech-smbx" \
    \
    -DCPACK_GENERATOR=DEB \
    -DCPACK_DEBIAN_PACKAGE_HOMEPAGE="https://wohlsoft.ru" \
    -DCPACK_DEBIAN_PACKAGE_RELEASE=1 \
    -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=amd64 \
    -DCPACK_DEBIAN_PACKAGE_DEPENDS="libsdl2-2.0-0, libpng16-16, libjpeg8" \
    -DCPACK_DEBIAN_PACKAGE_DESCRIPTION="The Super Mario fan game developed by Andrew Spinks in the past" \
..

# Build the project
ninja

# Pack the project
cpack .

Extra parameters for DEB that you can set: https://cmake.org/cmake/help/v3.14/cpack_gen/deb.html

Please edit this script to fit the thing into your local system specifics.

RPM example

Here is a little script example on how to make the RPM package for x86_64 architecture:

# Create a build directory
mkdir build-deb
cd build-deb

# Configure the build
cmake \
    -G Ninja \
    -DPGE_SHARED_SDLMIXER=OFF \
    -DUSE_SYSTEM_SDL2=ON \
    -DUSE_FREEIMAGE_SYSTEM_LIBS=ON \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=MinSizeRel \
    -DTHEXTECH_FIXED_ASSETS_PATH=/usr/share/games/smbx \
    -DTHEXTECH_SOURCE_ASSETS_PATH="/home/vitaly/.PGE_Project/a2xtech-packs/assets/thextech-smbx13-assets-full" \
    -DTHEXTECH_USER_DIR_NAME=".thextech-smbx" \
    -DDESKTOP_NAME="Super Mario Bros. X" \
    -DDESKTOP_GENERIC_NAME="Super Mario Bros. X" \
    -DDESKTOP_COMMENT="The Mario fan game" \
    -DTHEXTECH_EXECUTABLE_NAME="thextech-smbx" \
    -DTHEXTECH_PACKAGE_NAME="thextech-smbx" \
    \
    -DCPACK_GENERATOR=RPM \
    -DCPACK_RPM_PACKAGE_URL="https://wohlsoft.ru" \
    -DCPACK_RPM_PACKAGE_RELEASE=1 \
    -DCPACK_RPM_PACKAGE_ARCHITECTURE=x86_64 \
    -DCPACK_RPM_PACKAGE_REQUIRES="SDL2, libpng" \
    -DCPACK_RPM_PACKAGE_DESCRIPTION="The Super Mario fan game" \
..

# Build the project
ninja

# Pack the project
cpack .

Extra parameters for RPM that you can set: https://cmake.org/cmake/help/v3.14/cpack_gen/rpm.html

Please edit this script to fit the thing into your local system specifics.