Menu

LinuxBuild

Linux (3)
strobelight Dave Bullis Russell Shilling

Linux Build

Build Products

'Currently Linux Builds are done on Ubuntu 20.04 as 64-bt executables. We build for Ubuntu 20.04 (or later), Fedora
Applicable to V5.3.0 **Beta1 ** and later.
and their derivatives. We also build a elf-extracting shell script for old-style installs. Source tar balls are also produced.
All of these (and more) are available at the download directory. https://sourceforge.net/p/xtrkcad-fork/wiki/DownloadInstall/

XTrackCad has been built on a variety of Unix and Linux based systems. We can not provide support for these systems. Please contact your system maintainers for any issues you might have.

Build Prerequisites

The following apt commands are for a Debian/Ubuntu system. Equivalent commands are available of other systems.

Mercurial

Mercurial is the software control system used by the XTrackCad project.

apt install mercurial

You will probably want the GUI as well

apt install tortoisehg

Or visit http://mercurial-scm.org

CMake

CMake configures the build system and Makefiles.

apt install cmake cmake-curses-gui

Or visit http://cmake.org/download

Developer Tools

Install the compiler, pkg-config and gtk libs:

apt install g++ pkg-config libgtk2.0-dev

Libzip

Libzip is used to support .xtce format files. Currently XTrackCad uses version 4.

apt install libzip4 libzip-dev

For Releases, we use the static library (libzip.a) . For details please see [LinuxLibzip]

MiniXML

Creating SVG exports depends on the MiniXML: [https://www.msweet.org/mxml/] library. If this library cannot be found in the build system XTrackCAD is built anyway but won't include SVG export.

apt install libmxml-dev libmxml1

Icon Bitmaps

Most icons are built from .svg files.
To build the bitmap icons you need to install InkScape and FreeImage

You will need at least version 1.0 or Inkscape. You can install current version by

add-apt-repository ppa:inkscape.dev/stable
apt update
apt install inkscape

When running InkScape you may see warnings like

...dbind-WARNING **: 17:21:19.754: Couldn't register with accessibility bus:...

You can suppress this warning by

export NO_AT_BRIDGE=1

before building the project
You may want to put this in ~/.profile or ~/.bashrc.

Note: FreeImage is not needed for building post-5.3.0.
If you are building 5.3.0 and before you should do

apt install libfreeimage-dev

Doxygen

If you chose to build Doxygen (XTRKCAD_USE_DOXYGEN ON) you need to

apt install doxygen

Directory structure

You can have any structure you like, as long as your build directories are not descendants of your source directory.
This description assumes your project is ${SOURCE}/${BRANCH}/, where SOURCE is someplace where you do XTrackCad development and BRANCH is related to the Mercurial branch you're working on.

You can have any number of projects for different branches.

Create at least one build directory

$ mkdir -p ${SOURCE}/${BRANCH}/build

But eventually (after source fetch and build/install for debug) it will look like

src-branch/
build/
install/

Fetching Source

Obtain the current sources from Mercurial where USERNAME is your SourceForge user name.

$ cd ${SOURCE}/${BRANCH}
$ hg clone ssh://USERNAME@hg.code.sf.net/p/xtrkcad-fork/xtrkcad src-${BRANCH}
$ cd src-${BRANCH}
$ hg update ${BRANCH}

For readonly access use

$ hg clone http://hg.code.sf.net/p/xtrkcad-fork/xtrkcad src-${BRANCH}

Configuring the build

We will describe a debug build here.
Non-Debug builds are not required.

Change to the build directory and run ccmake to configure the build.

$ cd ${SOURCE}/${BRANCH}/build
$ ccmake ../src-${BRANCH}

Press the "c" key to configure the build.
After a few moments you will see some options to configure.

You only need to adjust the first two entries.
Use CMAKE_BUILD_TYPE to control the build type. Enter "Debug".
Use CMAKE_INSTALL_PREFIX to control where the software will be installed. For this example, we'll use "../install".
Use XTRKCAD_USE_DOXYGEN to enable the production of type, function, etc., documentation from the the source code. Requires doxygen if enabled. Enable if and only if you intend to hack on the code. See below.
Use XTRKCAD_USE_GETTEXT to add new locales (language translations). Choose "ON" to enable support for multiple languages.
Refer to http://www.xtrkcad.org/Wikka/Internationalization for additional information.

At this point your screen should look like

CMAKE_BUILD_TYPE Debug
CMAKE_INSTALL_PREFIX ../install
FreeImage_VERSION 3.18.0
INTL_LIBRARY INTL_LIBRARY-NOTFOUND
Inkscape_EXECUTABLE /usr/bin/inkscape
Inkscape_EXPORT --export-filename=
Inkscape_VERSION 1.3.2
LIBZIP_VERSION 1.7.3
MINIXML_STATIC_LIBRARY /usr/lib/x86_64-linux-gnu/libmxml.a
MiniXML_VERSION 3.2
XTRKCAD_USE_BROWSER ON
XTRKCAD_USE_DOXYGEN OFF
XTRKCAD_USE_GETTEXT ON
XTRKCAD_USE_GTK ON
ZLIB_VERSION 1.2.11

Toggle the advanced mode ('t') and set CMAKE_C_FLAGS to '-Wpointer-sign'
If you made any changes, press the "c" key again to update your new configuration.
Once everything is configured to your satisfaction, press the "g" key to generate makefiles for your build.

Building

Compile XTrackCad using your new configuration:

$ make

Installing

Install the new binary:

$ make install

Run

XTrackCad needs to know where it's support files have been installed.
For development purposes we can set the environment variable:

$ export XTRKCADLIB=../share/xtrkcad

Run the installed binary:

$ cd ../install/bin
$ ./xtrkcad

At this point you should run the #%Regression tests: [RegressionTesting]#%.

Beta Build

You have the option of building a normal release or a Beta release.
For a Beta release:
* the executable is xtrkcad-beta
* the install directory will be CMAKE_INSTALL_PREFIX/share/xtrkcad-beta
* the working directory will be ${HOME}/.xtrkcad-beta
* The XTRKCADLIB environment variable should be set to the working directory.

A Beta build is triggered by this line in ${SRCDIR}/ProgramVersion.cmake

set(XTRKCAD_VERSION_MODIFIER "Beta1")

If this value contains Beta then a Beta release will be built.
Otherwise, a normal release is built.

See LinuxInstall for run-time impacts of a Beta build.

Packaging

$ make package

This step will create the three install packages in the build directory.

If flatpak was detected, a flatpak target will be available:

$ make flatpak

This will create a .flatpak file in the build directory. For more information, see [Flatpak].

$ make package_source

This last step will create three source tarballs with various compression methods.
Note the build needs to be configured as described above.

Extras

If XTRKCAD_USE_DOXYGEN was enabled:

$ make docs-doxygen

to create the internals documentation. Read this documentation by pointing your web browser at ${SOURCE}/${BRANCH}/install/docs/doxygen/html/index.html.

XTrackCAD is reased for Ubuntu. Fedora and their derivates. But there is no official support for these operating systems.

CategoryDevel


Related

Wiki: BuildNotes
Wiki: Flatpak
Wiki: LinuxLibzip

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.