Build STK on Linux

(CMake: Add mention of IRRLICHT_INCLUDE_DIR)
m (Installing dependencies)
 
(44 intermediate revisions not shown)
Line 1: Line 1:
-
== Installing dependencies ==
+
Note that these instructions apply to STK versions more recent than 0.8 alpha. If you want to compile an older version, please use the history feature of the wiki.
-
First of all, you will need a compiler and the autotools build system. When building the current SVN, you will also need cmake. Other dependencies you will need include openal, ogg, vorbis.
+
<div class="outer_info">
 +
    <div class="inner_msg">
 +
'''If you are a packager making a package for a Linux distribution''', please do '''not''' try to modify our build system to use system versions of bullet and irrlicht. In both cases we use a specific and/or modified version of the library, and linking STK against the system library will only introduce bugs (corrupted graphics, memory leaks) into SuperTuxKart. Thanks
 +
</div></div>
-
* Fedora
 
-
<code>yum install gcc-c++ autoconf automake libogg-devel libvorbis-devel openal-soft-devel fribidi-devel subversion libcurl-devel cmake irrlicht-devel</code>
 
-
* Ubuntu
 
-
<code>sudo apt-get install autoconf automake build-essential cmake libogg-dev libvorbis-dev libopenal-dev libxxf86vm-dev libgl1-mesa-dev libglu1-mesa-dev libcurl4-openssl-dev libfribidi-dev</code>
 
-
== Installing Irrlicht ==
+
== Installing dependencies ==
-
Start by installing Irrlicht from your repositories, if it is found there. Otherwise check out [http://www.irrlicht3d.org/wiki/index.php?n=Main.InstallingIrrlicht How to Install Irrlicht] from the Irrlicht wiki.
+
First of all, you will need a c++ compiler, the autotools build system and cmake. Other dependencies you will need include openal, ogg, vorbis. You don't need to install irrlicht, bullet, enet or wiiuse because they are included in the git repository.
-
* SuperTuxKart 0.7.3 should be built using Irrlicht trunk revision 3843.
+
* Fedora
-
* If you want to compile the current SVN of STK, you will need a recent Irrlicht trunk but NOT the very latest trunk (I recommend revision 4098).
+
<code>yum install gcc-c++ autoconf automake git-core libogg-devel libvorbis-devel libXrandr-devel mesa-libGL-devel mesa-libGLU-devel openal-soft-devel fribidi-devel subversion libcurl-devel cmake libbluedevil-devel</code>
 +
* Ubuntu/Debian
 +
<code>sudo apt-get install autoconf automake build-essential cmake git libogg-dev libvorbis-dev libopenal-dev libxxf86vm-dev libgl1-mesa-dev libglu1-mesa-dev libcurl4-openssl-dev libfribidi-dev libfreetype6-dev libbluetooth-dev subversion libxrandr-dev zlib1g-dev libpng12-dev libjpeg-turbo8-dev libsm-dev</code>
-
The SVN repository of irrlicht may be found at
+
== Obtain code and assets ==
-
<code>https://irrlicht.svn.sourceforge.net/svnroot/irrlicht/trunk</code>
+
STK is splitted up into code and assets, so you need these two commands two get both:
 +
<code>git clone https://github.com/supertuxkart/stk-code.git stk-code # about 130 MB
 +
svn checkout https://svn.code.sf.net/p/supertuxkart/code/stk-assets stk-assets # about 650 MB</code>
 +
See [[Source control]] for more information.
-
Go in /source/Irrlicht inside that. Note that it's recommended to build Irrlicht in release mode for full performance (default is debug mode)
+
The <TT>stk-code</TT> and the <TT>stk-assets</TT> directory need to be in the same folder. This means that you need the following folder structure:
-
<code>NDEBUG=1 make</code>
+
* base dir
-
 
+
** stk-code
-
The build environment can use Irrlicht either from an installed package (e.g. in /usr/local), or directly from the source tree. CMake should automatically detect Irrlicht if it is installed in default directories (/usr, /usr/local). '''It is recommended not to install irrlicht to /usr or /usr/local if you build it from source. Just leave it in place, this will be cleaner.''' See [[#Building_SuperTuxKart|below]] to help the build system find your Irrlicht.
+
*** src
-
 
+
*** lib
-
If you have any problems with building irrlicht, please contact the irrlicht developers in their forum, since we most likely won't have the expertise to help with that.
+
*** ...
 +
** stk-assets
 +
*** tracks
 +
*** ...
== Building SuperTuxKart ==
== Building SuperTuxKart ==
-
As of 0.7.3, you may use either CMake or autotools to build SuperTuxKart. In the current SVN, autotools isn't actively being maintained any more. As such, use of CMake is encouraged.
+
Next, build SuperTuxKart using CMake:
-
=== CMake ===
+
<code>cd stk-code
-
<code>mkdir cmake_build
+
mkdir cmake_build
cd cmake_build
cd cmake_build
cmake ..
cmake ..
-
make
+
make -j2
</code>
</code>
-
or, if Irrlicht is not installed system-wide, replace the 'cmake' part with:
+
You can speed up compilation heavily by changing the number behind <tt>-j</tt> to the number of cores you have.
-
<code>cmake .. -DIRRLICHT_DIR=/full/path/to/irrlicht</code>
+
=== CMake Options ===
 +
There is a varity ofCMake options. The most important ones are listed below:
 +
* To make a debug build add <tt>-DCMAKE_BUILD_TYPE=Debug</tt> like this: <code>cmake .. -DCMAKE_BUILD_TYPE=Debug</code>
-
Note: if Irrlicht is installed system-wide, it may sometimes be necessary to also add <tt>-DIRRLICHT_INCLUDE_DIR</tt>. This would then be set to the <tt>include</tt> directory in your Irrlicht directory, eg
+
* Another option is to build the regular release version with its optimizations, but with debugging symbols still enabled. Replace the <tt>Debug</tt> with <tt>RelWithDebInfo</tt> for that, ie: <code>cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo</code>
-
<code>cmake .. -DIRRLICHT_DIR=/full/path/to/irrlicht -DIRRLICHT_INCLUDE_DIR=/full/path/to/irrlicht/include</code>
+
* wiiuse can be enable with <code>-DUSE_WIIUSE=yes</code>
-
to make a debug build add <tt>-DCMAKE_BUILD_TYPE=Debug</tt> like this:
 
-
<code>cmake .. -DCMAKE_BUILD_TYPE=Debug</code>
+
Finally, you can simply run SuperTuxKart from the build directory:
 +
<code>./bin/supertuxkart</code>
-
Another option is to build the regular release version with its optimizations, but with debugging symbols still enabled. Replace the <tt>Debug</tt> with <tt>RelWithDebInfo</tt> for that.
+
Optionally, STK can be installed /usr/local in using
-
And (optionally) to install:
+
<code>sudo make install</code>''
-
<code>sudo make install</code>
+
If you want to install somewhere else, add the following options to cmake:
-
this will install in /usr/local. If you want to install somewhere else, replace the "cmake" command with something like:
+
<code>-DCMAKE_INSTALL_PREFIX=/path/to/install</code>
-
<code>cmake .. -DCMAKE_INSTALL_PREFIX=/opt/stk</code>
+
If you want to update your copy of STK to the current git/SVN versions, go to the parent directory of stk-code:
 +
<code>cd stk-code
 +
git pull
 +
cd cmake_build
 +
make -j2
 +
cd ../../stk-assets
 +
svn update</code>
-
Our CMake build system is younger so we welcome success/failure stories :)
+
== Using Eclipse ==
 +
If you want to use the eclipse ide, use the following approach:
-
=== Autotools ===
+
In the trunk :
-
 
+
    mkdir cmake_build
-
''Note: This method is not actively being maintained in the current SVN. While it will often still work, the use of cmake is strongly advised.''
+
    cd cmake_build
-
 
+
    cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
-
Simply use the usual autotools build triplet :
+
-
<code>./configure
+
-
make
+
-
</code>
+
-
and optionally
+
This will generate project files based on the cmake files.
-
<code>sudo make install</code>
+
Now you can open Eclipse, Import -> Existing projects into workspace, browse to the trunk and import the build project.
-
(if you obtained the STK source code from SVN, you will first need to run <TT>./autogen.sh</TT>)
+
Though, I recommend making a new project with the trunk as directory so that you can actually browse the source in the IDE and use the source control (SVN/GIT) plugins.
 +
Now right-click on this project -> New -> Convert to C++ Project (Possibly not needed if you made a C++ project in the previous step.)
-
If irrlicht is not installed system-wide, replace the './configure' part with :
+
Right-click the project -> properties -> C/C++ Build
 +
* Uncheck "Use default build command"
 +
* Enter as build command "make -j2" (replace 2 by the number of cores)
 +
* Change the build directory to cmake_build
-
<code>./configure --with-irrlicht=/full/path/to/irrlicht</code>
+
Now you can build the project by :
 +
* Right-click project -> Build Project
 +
* Or by using the build button at the top
-
== Troubleshooting ==
+
For easier code browsing an making use of Eclipse features :
-
Depending on whether your irrlicht build uses internal or external libpng/libjpeg dependencies, you may need to configure STK this way :
+
C/C++ Build -> Discovery options
 +
* Automate discovery of path and symbols
 +
* Discovery profile : GCC per project scanner into profile
 +
Apply
-
<code>./configure LDFLAGS="-lpng -ljpeg -lbz2"</code>
+
Right-click project -> index -> rebuild

Latest revision as of 22:06, 18 March 2016

Note that these instructions apply to STK versions more recent than 0.8 alpha. If you want to compile an older version, please use the history feature of the wiki.

If you are a packager making a package for a Linux distribution, please do not try to modify our build system to use system versions of bullet and irrlicht. In both cases we use a specific and/or modified version of the library, and linking STK against the system library will only introduce bugs (corrupted graphics, memory leaks) into SuperTuxKart. Thanks


Contents

Installing dependencies

First of all, you will need a c++ compiler, the autotools build system and cmake. Other dependencies you will need include openal, ogg, vorbis. You don't need to install irrlicht, bullet, enet or wiiuse because they are included in the git repository.

yum install gcc-c++ autoconf automake git-core libogg-devel libvorbis-devel libXrandr-devel mesa-libGL-devel mesa-libGLU-devel openal-soft-devel fribidi-devel subversion libcurl-devel cmake libbluedevil-devel

sudo apt-get install autoconf automake build-essential cmake git libogg-dev libvorbis-dev libopenal-dev libxxf86vm-dev libgl1-mesa-dev libglu1-mesa-dev libcurl4-openssl-dev libfribidi-dev libfreetype6-dev libbluetooth-dev subversion libxrandr-dev zlib1g-dev libpng12-dev libjpeg-turbo8-dev libsm-dev

Obtain code and assets

STK is splitted up into code and assets, so you need these two commands two get both: git clone https://github.com/supertuxkart/stk-code.git stk-code # about 130 MB svn checkout https://svn.code.sf.net/p/supertuxkart/code/stk-assets stk-assets # about 650 MB See Source control for more information.

The stk-code and the stk-assets directory need to be in the same folder. This means that you need the following folder structure:

Building SuperTuxKart

Next, build SuperTuxKart using CMake:

cd stk-code mkdir cmake_build cd cmake_build cmake .. make -j2

You can speed up compilation heavily by changing the number behind -j to the number of cores you have.

CMake Options

There is a varity ofCMake options. The most important ones are listed below:


Finally, you can simply run SuperTuxKart from the build directory: ./bin/supertuxkart

Optionally, STK can be installed /usr/local in using

sudo make install

If you want to install somewhere else, add the following options to cmake:

-DCMAKE_INSTALL_PREFIX=/path/to/install

If you want to update your copy of STK to the current git/SVN versions, go to the parent directory of stk-code: cd stk-code git pull cd cmake_build make -j2 cd ../../stk-assets svn update

Using Eclipse

If you want to use the eclipse ide, use the following approach:

In the trunk :

   mkdir cmake_build
   cd cmake_build
   cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..

This will generate project files based on the cmake files.

Now you can open Eclipse, Import -> Existing projects into workspace, browse to the trunk and import the build project.

Though, I recommend making a new project with the trunk as directory so that you can actually browse the source in the IDE and use the source control (SVN/GIT) plugins.

Now right-click on this project -> New -> Convert to C++ Project (Possibly not needed if you made a C++ project in the previous step.)

Right-click the project -> properties -> C/C++ Build

Now you can build the project by :

For easier code browsing an making use of Eclipse features :

C/C++ Build -> Discovery options

Apply

Right-click project -> index -> rebuild

Retrieved from "http://supertuxkart.sourceforge.net/Build_STK_on_Linux"

User Tools