DarkRadiant - Compiling in Linux: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
 
(31 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Install Required Packages ==
== Install Required Packages ==


=== Ubuntu 20.04 ===
=== Ubuntu 22.10 and later ===


Copy and paste the following into a terminal:
Copy and paste the following into a terminal:


  sudo apt-get install git g++ gettext automake libtool pkg-config zlib1g-dev libjpeg62-dev libxml2-dev libsigc++-2.0-dev
  sudo apt-get install git g++ gettext cmake pkg-config libxml2-dev libsigc++-2.0-dev libftgl-dev libglew-dev libjpeg-dev
  sudo apt-get install libwxgtk3.0-gtk3-dev libpng-dev libftgl-dev libglew-dev libalut-dev libvorbis-dev python3-dev pybind11-dev
  sudo apt-get install libalut-dev libvorbis-dev libwxgtk3.2-dev libglib2.0-dev libeigen3-dev python3-dev libgtest-dev libgit2-dev


=== Ubuntu 19.xx / 18.xx / 17.xx ===
=== Ubuntu 20.04 to 22.04 ===


Copy and paste the following into a terminal:
Copy and paste the following into a terminal:


  sudo apt-get install git g++ gettext automake libtool pkg-config zlib1g-dev libjpeg62-dev libwxgtk3.0-dev libxml2-dev  
  sudo apt-get install git g++ gettext cmake pkg-config zlib1g-dev libjpeg-dev libxml2-dev libsigc++-2.0-dev libgtest-dev libeigen3-dev
  sudo apt-get install libsigc++-2.0-dev libpng-dev libftgl-dev libglew-dev python-dev libalut-dev libvorbis-dev pybind11-dev
  sudo apt-get install libwxgtk3.0-gtk3-dev libpng-dev libftgl-dev libglew-dev libalut-dev libvorbis-dev python3-dev libgit2-dev


=== Debian 9 ===
=== openSUSE Tumbleweed ===


Copy and paste the following into a terminal:
Copy and paste the following into a terminal:


  sudo apt-get install git automake libtool pkg-config gettext zlib1g-dev libjpeg62-turbo-dev libwxgtk3.0-dev
  sudo zypper install git cmake gcc-c++ gettext-tools zlib-devel libjpeg62-devel libxml2-devel libsigc++2-devel gtest
sudo apt-get install libxml2-dev libsigc++-2.0-dev libpng-dev libftgl-dev libglew-dev libalut-dev libvorbis-dev python-dev pybind11-dev
sudo zypper install wxWidgets-3_0-devel ftgl-devel glew-devel libvorbis-devel freealut-devel python38-devel


=== Ubuntu 16.10 x64 / Kubuntu 16.10 x64 ===
=== Mageia 8 ===
 
Copy and paste the following into a terminal, run as user who has the required permissions to install the packages:
 
sudo urpmi git cmake make gcc-c++ libzlib-devel libjpeg-devel libwxgtku3.0-devel libsigc++2.0-devel
sudo urpmi libftgl-devel libglew-devel libpython3-devel libopenal-devel libfreealut-devel libvorbis-devel lib64gtest-devel
 
=== Debian 10 ===


Copy and paste the following into a terminal:
Copy and paste the following into a terminal:


  sudo apt-get install git g++ gettext automake libtool pkg-config zlib1g-dev libjpeg62-dev libwxgtk3.0-dev libxml2-dev  
  sudo apt-get install git cmake pkg-config gettext zlib1g-dev libjpeg-dev libwxgtk3.0-dev libgtest-dev libeigen3-dev libgit2-dev
  sudo apt-get install libsigc++-2.0-dev libpng-dev libftgl-dev libglew-dev python-dev libalut-dev libvorbis-dev
  sudo apt-get install libxml2-dev libsigc++-2.0-dev libpng-dev libftgl-dev libglew-dev libalut-dev libvorbis-dev python3-dev


=== Fedora 26 / 25 ===
=== Fedora 26 / 25 ===
Line 38: Line 45:


=== Arch Linux ===
=== Arch Linux ===
The following packages are requred after starting from an Anarchy installation using Gnome as Window Manager.  
The following packages are required after starting from an Anarchy installation using Gnome as Window Manager.  
 
sudo pacman -S automake libtool wxgtk ftgl glew freealut pybind11
 
=== openSUSE 42.2 ===
 
openSUSE 42 is complicated, as it ships with a rather dated GCC 4.8 which doesn't support all C++11 features like std::regex. This causes a few problems which we need to tackle one after the other:
 
* We need to install a newer compiler
* We need to build wxWidgets 3.0.x ourselves (otherwise DR would refuse to start, since wxWidgets is checking the GCC ABI Compatibility at startup and bails out as the wxWidgets library shipping with openSUSE was built with a different GCC version)
* We need to point DarkRadiant to the folder where it can find the homegrown wxWidgets binaries (through LD_LIBRARY_PATH)
 
Install the newer GCC5 by opening YaST2 and go to Software Management, then type in gcc5 in the search box. I chose the following two packages:
 
gcc5-g++
libstd++6-gcc5


Then install a couple of base libraries needed for DarkRadiant:
sudo pacman -S cmake wxgtk3 ftgl glew freealut libvorbis python libsigc++ eigen


sudo zypper install git make libtool automake gcc-c++ zlib-devel libjpeg62-devel gettext-tools
=== Manjaro ===
sudo zypper install libxml2-devel libsigc++2-devel ftgl-devel glew-devel boost-devel python-devel libvorbis-devel freealut-devel
The following packages are required:
 
  sudo pacman -S cmake base-devel wxgtk3 ftgl glew freealut libvorbis python libsigc++ eigen
Download and extract the source tarball for wxWidgets (I'll assume this is in your home folder ~/):
 
wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3/wxWidgets-3.0.3.tar.bz2
tar -xvf wxWidgets-3.0.3.tar.bz2
cd wxWidgets-3.0.3
 
Point the configure script to the newer compiler using the CXX= prefix:
 
CXX="g++-5" ./configure --with-opengl --prefix=/home/greebo/wx_install && make -j3 && make install
 
This will place the wxWidgets binaries into your <tt>/home/greebo/wx_install/lib64</tt> folder (where DarkRadiant will need to be pointed at later on).
Compile DarkRadiant from source as the next step (assuming you cloned the sources into your home folder), point the configure script to the
wx-config binary we previously installed in <tt>~/wx_install/bin</tt>.
cd ~/DarkRadiant
CXX="g++-5" ./configure --enable-darkmod-plugins --prefix=/home/greebo/dr_install --with-wx-config=/home/greebo/wx_install/bin/wx-config
CXX="g++-5" make -j3 && make install
This will place the DarkRadiant executable into the /home/greebo/dr/bin/ folder after a successful build. To launch DarkRadiant, specify an LD_LIBRARY_PATH environment variable otherwise it will refuse to start, claiming something like ''"error while loading shared libraries: libwx_gtk2u_gl-3.0.so.0: cannot open shared object file"''
LD_LIBRARY_PATH=~/wx_install/lib64 ~/dr_install/bin/darkradiant
 
=== Ubuntu 15.10 x64 / Kubuntu 16.04 x64 ===
 
Copy and paste the following into a terminal:
 
sudo apt-get install git automake libtool pkg-config zlib1g-dev libjpeg62-dev libwxgtk3.0-dev libxml2-dev libsigc++-2.0-dev
sudo apt-get install libpng12-dev libftgl-dev libglew-dev libboost-dev libboost-test-dev libalut-dev libvorbis-dev
 
=== Debian 8.2 ===
 
The same instructions as for Ubuntu 15.10 should work, but instead use this command line to install the dependencies (the libjpeg package is named differently):
 
sudo apt-get install git automake libtool pkg-config zlib1g-dev libjpeg62-turbo-dev libwxgtk3.0-dev libxml2-dev libsigc++-2.0-dev
sudo apt-get install libpng12-dev libftgl-dev libglew-dev libboost-dev libboost-test-dev libalut-dev libvorbis-dev
 
=== Mageia 5.1 x64 ===
 
Copy and paste the following into a terminal, run as user who has the required permissions to install the packages:
 
  sudo urpmi git automake libtool gcc-c++ libzlib-devel libjpeg-devel libwxgtku3.0-devel libsigc++2.0-devel libftgl-devel
sudo urpmi libglew-devel libboost-devel libpython-devel libopenal-devel libfreealut-devel libvorbis-devel


=== CentOS 7 x64 ===
=== CentOS 7 x64 ===
Line 166: Line 119:
Or look into the [https://wiki.gentoo.org/wiki/Project:Portage/Sync various ways to hook into the portage sync system].
Or look into the [https://wiki.gentoo.org/wiki/Project:Portage/Sync various ways to hook into the portage sync system].


=== Distributions with GCC 4.8 or earlier ===
=== Building with a non-default g++ Compiler ===
DarkRadiant's codebase makes heavy use of C++11 features, in particular std::regex which has been supported from GCC 4.9 on. Not all distributions ship with g++ 4.9 by default (for example Ubuntu 14.04 does not), but it's possible to install a more recent compiler suite. Get the GCC 4.9 package and ensure that the makefiles are called with the correct setup, e.g.
DarkRadiant's codebase makes use of C++17 features, in particular std::filesystem. Not all distributions ship with a compatible g++ compiler by default, but it's possible to install a more recent compiler suite. Get the compiler package and ensure that the makefiles are called with the correct setup, e.g.
  CXX="g++-4.9" ./configure --enable-darkmod-plugins && make -j3 && make install
  CXX="g++-5.1" cmake . && make && make install


=== Older Distributions / Compiling DarkRadiant 1.8 and older ===
=== Older Distributions / Compiling DarkRadiant 1.8 and older ===
Line 178: Line 131:
Next, change to the directory where you want the source code to be in and then clone the Git repository with:
Next, change to the directory where you want the source code to be in and then clone the Git repository with:


  git clone git://github.com/codereader/DarkRadiant.git
  git clone https://github.com/codereader/DarkRadiant.git


Once the initial clone is done, the source can be updated to the latest version from inside the working directory with:
Once the initial clone is done, the source can be updated to the latest version from inside the working directory with:
Line 185: Line 138:


== Configure and Compile ==
== Configure and Compile ==
DarkRadiant employs an Autoconf/Automake build system under Linux as used in the majority of open-source projects. Make sure you have the automake toolchain downloaded, this is covered in the package installation commands above.
DarkRadiant employs the CMake build system under Linux as used in many open-source projects. Make sure you have the CMake toolchain downloaded, this is covered in the package installation commands above.
 
As first step, run
./autogen.sh
in your darkradiant folder to update the makefiles and scripts.


Afterwards, run the typical chain of configure and make commands:
To build DarkRadiant, run the typical chain of CMake and make commands:


  ./configure --enable-darkmod-plugins
  cmake .
  make
  make
  make install
  [sudo] make install


By the above, a release build will be created; if a debug build is required pass the <tt>--enable-debug</tt> option to the configure script.
By the above, a release build will be created; if a debug build is required pass the <tt>-DCMAKE_BUILD_TYPE=Debug</tt> option to the cmake command script.


Other points to note about the configure process:
Other points to note about the configure process:


* The DarkMod-specific plugins are not built by default, the <tt>--enable-darkmod-plugins</tt> argument will enable them.
* The DarkMod-specific plugins are built by default, the <tt>-DENABLE_DM_PLUGINS=OFF</tt> argument will disable them.
* The configure script autodetects required dependencies, and will conditionally enable optional components of DarkRadiant (such as the sound plugin) based on what it finds.
* The CMake script autodetects required dependencies, and will conditionally enable optional components of DarkRadiant (such as the sound plugin) based on what it finds.
* For quick testing of a DarkRadiant build, it is desirable to install it into a temporary location rather than the default of <tt>/usr/local</tt>; for this, simply pass a prefix option such as <tt>--prefix=/tmp/dr</tt> to configure, after which DarkRadiant will be installed in <tt>/tmp/dr/bin/darkradiant</tt>.
* For quick testing of a DarkRadiant build, it is desirable to install it into a temporary location rather than the default of <tt>/usr/local</tt>; for this, simply pass a prefix option such as <tt>-DCMAKE_INSTALL_PREFIX=/tmp/dr</tt> to cmake, after which DarkRadiant will be installed in <tt>/tmp/dr/bin/darkradiant</tt>.
* In cases where <tt>wx-config</tt> cannot be found even though the corresponding wxGTK-devel package has been installed (Configure errors with <tt>"checking for wx-config... no"</tt>), check your <tt>/usr/bin</tt> folder for a similarly named file, e.g. in CentOS it's called <tt>/usr/bin/wx-config-3.0</tt>. Pass the path to this file to configure like this: <tt>--with-wx-config=/usr/bin/wx-config-3.0</tt>


=== Multiprocessor Systems ===
=== Multiprocessor Systems ===

Latest revision as of 09:50, 13 January 2024

Install Required Packages

Ubuntu 22.10 and later

Copy and paste the following into a terminal:

sudo apt-get install git g++ gettext cmake pkg-config libxml2-dev libsigc++-2.0-dev libftgl-dev libglew-dev libjpeg-dev
sudo apt-get install libalut-dev libvorbis-dev libwxgtk3.2-dev libglib2.0-dev libeigen3-dev python3-dev libgtest-dev libgit2-dev

Ubuntu 20.04 to 22.04

Copy and paste the following into a terminal:

sudo apt-get install git g++ gettext cmake pkg-config zlib1g-dev libjpeg-dev libxml2-dev libsigc++-2.0-dev libgtest-dev libeigen3-dev
sudo apt-get install libwxgtk3.0-gtk3-dev libpng-dev libftgl-dev libglew-dev libalut-dev libvorbis-dev python3-dev libgit2-dev

openSUSE Tumbleweed

Copy and paste the following into a terminal:

sudo zypper install git cmake gcc-c++ gettext-tools zlib-devel libjpeg62-devel libxml2-devel libsigc++2-devel gtest
sudo zypper install wxWidgets-3_0-devel ftgl-devel glew-devel libvorbis-devel freealut-devel python38-devel

Mageia 8

Copy and paste the following into a terminal, run as user who has the required permissions to install the packages:

sudo urpmi git cmake make gcc-c++ libzlib-devel libjpeg-devel libwxgtku3.0-devel libsigc++2.0-devel 
sudo urpmi libftgl-devel libglew-devel libpython3-devel libopenal-devel libfreealut-devel libvorbis-devel lib64gtest-devel

Debian 10

Copy and paste the following into a terminal:

sudo apt-get install git cmake pkg-config gettext zlib1g-dev libjpeg-dev libwxgtk3.0-dev libgtest-dev libeigen3-dev libgit2-dev
sudo apt-get install libxml2-dev libsigc++-2.0-dev libpng-dev libftgl-dev libglew-dev libalut-dev libvorbis-dev python3-dev

Fedora 26 / 25

Copy and paste the following into a terminal:

sudo dnf install git automake libtool gcc-c++ zlib-devel libjpeg-turbo-devel wxGTK3-devel libxml2-devel libsigc++20-devel 
sudo dnf install libpng12-devel ftgl-devel glew-devel libvorbis-devel freealut-devel python-devel pybind11-devel

Note that the wxGTK package does not yet support Wayland environments, which is the default since Fedora 25 (DarkRadiant will just segfault during startup). You'll need to deactivate it for the moment being.

Arch Linux

The following packages are required after starting from an Anarchy installation using Gnome as Window Manager.

sudo pacman -S cmake wxgtk3 ftgl glew freealut libvorbis python libsigc++ eigen

Manjaro

The following packages are required:

sudo pacman -S cmake base-devel wxgtk3 ftgl glew freealut libvorbis python libsigc++ eigen

CentOS 7 x64

Copy and paste the following into a terminal, run as user who has the required permissions to install the packages:

sudo yum -y install gcc gcc-c++ git automake libtool zlib-devel libjpeg-turbo-devel wxGTK3-devel libxml2-devel 
sudo yum -y install libsigc++20-devel ftgl-devel glew-devel boost-devel openal-soft-devel freealut-devel libvorbis-devel python-devel

CentOS 7 ships with an older compiler, so you'll need to install a more recent GCC first (following the directions on stackoverflow):

sudo yum install centos-release-scl 
sudo yum install devtoolset-4-gcc*
scl enable devtoolset-4 bash

Note that the wxGTK3-devel package doesn't create a wx-config symlink in the /usr/bin directory, that's why you need to pass an additional --with-wx-config=/usr/bin/wx-config-3.0 argument to the ./configure script below, like this:

./configure --enable-darkmod-plugins --with-wx-config=/usr/bin/wx-config-3.0

Slackware 14.2

Slackware doesn't provide precompiled packages on the one hand (unlike Debian or Arch), but already ships with a lot of libraries on the other. Stuff like git, automake, libtools and development libraries like zlib and boost are already present, but wxWidgets, openAL, ALut and FTGL need to be installed by means of a SlackBuild script. The following has been done in Slackware 14.2, so your mileage may vary.

Download the Source tarballs and the SlackBuild packages from these URLs:

Download and extract the SlackBuild .tar.gz files in your ~/Downloads folder (or anywhere else where you want to have them). For instance, the wxGTK3 package can be untar'd like this:

tar xzf wxGTK3.tar.gz
cd wxGTK3
chmod +x wxGTK3.SlackBuild

Do this for all of the above libraries, that should give you the directories ftgl/, OpenAL/, wxGTK3/ and freealut/. Next, download the Source Tarballs (the .tar.bz2) files from the links above and place them next to the corresponding SlackBuild script. Then run the scripts for each of them and install the build output in your system in a second step:

./wxGTK3.SlackBuild

This produced (on my end at least) the package /tmp/wxGTK3-3.0.2-i486-2_SBo.tgz which can be installed by the installpkg command:

installpkg /tmp/wxGTK3-3.0.2-i486-2_SBo.tgz

Do the same for the rest of the libraries (ftgl, OpenAL, freealut). Be aware that the freealut package depends on the OpenAL package, so you need to do the OpenAL one first. Once you have these installed, you can proceed to the build section (git clone and configure and make).

Gentoo

DarkRadiant can be built and installed from an unofficial ebuild repository (overlay). The easiest way to do this is with app-portage/layman, which must be installed with the git use flag.

In the 'overlays' section in /etc/layman/layman.cfg, add:

https://raw.githubusercontent.com/varingst/varingst-overlay/master/overlay.xml

Then fetch and add the overlay:

# layman -f -a varingst

Now that the overlay is added, you can build and install DarkRadiant with Portage:

# emerge darkradiant

To sync the overlay, either do it manually with layman:

# layman -s varingst

Or look into the various ways to hook into the portage sync system.

Building with a non-default g++ Compiler

DarkRadiant's codebase makes use of C++17 features, in particular std::filesystem. Not all distributions ship with a compatible g++ compiler by default, but it's possible to install a more recent compiler suite. Get the compiler package and ensure that the makefiles are called with the correct setup, e.g.

CXX="g++-5.1" cmake . && make && make install

Older Distributions / Compiling DarkRadiant 1.8 and older

The instructions about how to compile DR 1.8 (based on GTK) in distributions published in 2012 and older have been removed. They should still be in the history of this page, should they ever be needed.

Obtain the source

Make sure you have the git client installed, this is covered in the package installation commands above. Next, change to the directory where you want the source code to be in and then clone the Git repository with:

git clone https://github.com/codereader/DarkRadiant.git

Once the initial clone is done, the source can be updated to the latest version from inside the working directory with:

git pull

Configure and Compile

DarkRadiant employs the CMake build system under Linux as used in many open-source projects. Make sure you have the CMake toolchain downloaded, this is covered in the package installation commands above.

To build DarkRadiant, run the typical chain of CMake and make commands:

cmake .
make
[sudo] make install

By the above, a release build will be created; if a debug build is required pass the -DCMAKE_BUILD_TYPE=Debug option to the cmake command script.

Other points to note about the configure process:

  • The DarkMod-specific plugins are built by default, the -DENABLE_DM_PLUGINS=OFF argument will disable them.
  • The CMake script autodetects required dependencies, and will conditionally enable optional components of DarkRadiant (such as the sound plugin) based on what it finds.
  • For quick testing of a DarkRadiant build, it is desirable to install it into a temporary location rather than the default of /usr/local; for this, simply pass a prefix option such as -DCMAKE_INSTALL_PREFIX=/tmp/dr to cmake, after which DarkRadiant will be installed in /tmp/dr/bin/darkradiant.

Multiprocessor Systems

You can pass the --jobs=N parameter to make:

make --jobs=2

to use more than one processor for the compilation. This will eat lots of RAM, so don't do this on machines with little available memory.

Building a .deb package

To build a Debian/Ubuntu package, simply run

dpkg-buildpackage -rfakeroot

in the main darkradiant directory. The .deb will be created in the parent directory.