Building on Linux or xBSD - TheXTech/TheXTech GitHub Wiki

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

Build

These instructions should work regardless of your experience, but they don't include all the explanations of how systems like git submodules or the CMake configure/build process work. Please look these up if you have any confusion as you are building.

Preparing to build

Before to start the build, you should obtain the source code for TheXTech. You can use the stable version as well as the latest in-development to test out any new experimental features and receive any further bugfixes earlier.

Stable version

If you want to build the stable version, you can simply download the source code archive from the official site or from GitHub releases:

And then, unpack the archive and open the terminal at the just-now unpacked directory that contains the source code for TheXTech.

Important note: Please never use the "Source code" links at Github releases: they are broken. Instead, download the thextech-full-src-v*.*.*.tar.gz or thextech-full-src-v*.*.*.tar.bz2 or thextech-full-src-v*.*.*.zip archive.

This project uses submodules and GitHub is unable to create source code packages that includes submodules too.

Development version

If you want to build the latest in-development version, then, instead of downloading the archive, you can clone the repository itself by running this in a terminal (please open the terminal at the directory where you want to put the clonned repository, so, you will know where it is):

git clone --recurse-submodules https://github.com/TheXTech/TheXTech.git

If your version of git doesn't support --recurse-submodules, you cloned without it, or a new submodule has been added to the repository since you cloned: manually initialize and update all submodules. Otherwise, it won't build.

git submodule init
git submodule update

Building

At the TheXTech's source code directory, run next commands in the terminal:

  1. Make the building directory:

    mkdir build
    cd build
    
  2. 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 (this example uses Ninja)

    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: If build fails on your systems with PNG build errors, please add the -DUSE_FREEIMAGE_SYSTEM_LIBS=ON flag to use PNG and JPEG libraries from the system if the project gets unbuildable.

  3. Run the build itself:

    If you generated regular GNU Makefiles in the last step:

    # 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
    

    If you generated build.ninja files (using cmake -G Ninja ..., such as in the release example) in the last step:

    ninja
    

    Now, you should be able to find your binaries in output/bin. See the next section for how to run them!

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.