Building Spring on Linux: Difference between revisions

From Spring
Jump to navigationJump to search
 
(109 intermediate revisions by 31 users not shown)
Line 1: Line 1:
== Build From Source ==
[[Engine_Development|Development]] < [[Building_spring|Building Spring]] < {{FULLPAGENAME}}


'''You might encounter sync errors in online play if you are not using the exact same version of the compiler and same compiler settings as used for prebuilt packages!'''
= Build From Source on Linux =
If you prefer to use your distributions package system (release versions only), refer to the Linux [[SetupGuide]].


For 0.76b1 these are: TODO add them here.
If there is no package tailored for your distribution, you have to install from sources manually. Doing this for distributions where packages are available is not recommended.
 
<span class=warning>'''Warning:'''<br/>
'''Be careful when building from source.'''<br/>
You might encounter sync errors in online play if:
* you are using an untested compiler (''gcc'' from the >=4.6 series should be safe)
* you use non-standard compiler settings (be careful about ''-march'')!
</span>
 
== Obtaining the Source ==
{{Obtaining_The_Source_Code}}


If there is no package tailored for your distribution, you have to install from sources manually. Doing this for distributions where packages are available is not recommended.
= Get Dependencies =
 
To compile, you will have to install some development packages Spring depends on. These vary from distro to distro and may also depend on your specific configuration.
 
If your distributions is not listed below, you should be able to figure out the correct package names from this.


=== Get Source ===
== Full list ==
* Programs necessary to build
** ''cmake''
** ''7zip'' (aka ''p7zip'' or ''7z'')
** The usual build toolchain
*** ''gcc''
*** ''make''
* Libraries
** SDL2
** ''libdeviL'' (IL)
** OpenAL (openal-soft, older openal-0.0.8 does not work)
** OpenGL headers (mesa, GLEW, etc.)
** ''zlib''
** ''freetype'' (2)
** ''ogg'', ''vorbis'' and ''vorbisfile''
** ''curl''
* Optional (for AI Interfaces, Skirmish AIs and unit tests)
** ''python'' (2.5+)
** ''jdk'' (1.5+)
** ''boost'' (version 1.47 or later)
*** ''chrono''
*** ''filesystem''
*** ''threads''
*** ''system''
*** ''chrono''


You can either download the source as a 3.9MB tarball (recommended; v. 0.76b1) or get it from the subversion repository. Either way, the result is the same.
== Debian ==


==== Tarball ====
For Jessie (debian 8.0 stable) this should work:


<code><pre>
<pre>
cd /usr/local/src # or /var/tmp, or whatever
sudo apt-get install build-essential zlib1g-dev libfreetype6-dev cmake \
wget http://spring.clan-sy.com/dl/spring_0.76b1_src.tar.bz2
libsdl2-dev libopenal-dev libglew-dev zip libvorbis-dev libxcursor-dev \
tar xjf spring_0.76b1_src.tar.bz2
libdevil-dev libboost-system1.55-dev libboost-thread1.55-dev \
cd spring_0.76b1
libboost-regex1.55-dev libboost-serialization1.55-dev \
</pre></code>
libboost-program-options1.55-dev libboost-chrono1.55-dev \
libunwind-dev  libboost-filesystem1.55-dev \
libboost-signals1.55-dev libboost-test1.55-dev \
xsltproc libfontconfig1-dev libcurl4-openssl-dev
</pre>


'''NOTE: The .zip release is for windows only. Linux users have to get .bz2 like shown above.'''


==== Subversion ====
=== Ubuntu  ===
<pre>
# compiler and build tools
sudo apt-get install build-essential cmake cmake-gui git


<code><pre>
# spring dependencies
aptitude install subversion # if you are not on debian, figure it out
sudo apt-get install libglew-dev libsdl2-dev libdevil-dev libopenal-dev \
svn co https://spring.clan-sy.com/svn/spring/tags/spring_0.76b1 \
libogg-dev libvorbis-dev libfreetype6-dev p7zip-full libxcursor-dev \
/usr/local/src/spring_0.76b1
libboost-thread-dev libboost-regex-dev libboost-system-dev \
cd /usr/local/src/spring_0.76b1
libboost-program-options-dev libboost-signals-dev \
</pre></code>
libboost-chrono-dev libboost-filesystem-dev libunwind8-dev \
default-jdk libcurl4-gnutls-dev
</pre>


If the above subversion host happens to be down (which is unlikely since you're reading this wiki page now), you can try the following hourly updated mirror (replace the svn co line above with the following line):
to speed up compiling/linking, you can install gold, an alternative linker and when you plan to develop / recompile often ccache :
<code><pre>
svn co svn://caspring.org:3691/tags/spring_0.76b1 \
/usr/local/src/spring_0.76b1
</pre></code>


=== Dependencies ===
<pre>sudo apt-get install binutils-gold ccache</pre>


You will need to install some development packages Spring depends on. These vary from distro to distro and may also depend on your specific configuration.


If your distributions is not listed below, you should be able to figure out the correct package names from this. The scons configure will whine if you forget something, but it does not check if you remembered to install zip, even though you still need it.
to make ccache useful, the cache size needs to be increased by:


==== Debian ====
<pre>ccache -M 5G</pre>


For Etch (debian 4.0 stable) and Sid (debian unstable), I've confirmed the
to set it to 5GB.
following to be the minimal set that is necessary to get. I have not tested
with any version of Ubuntu, but the line is probably almost identical if not
the same. Quilted tested with ubuntu fiesty fawn on july 28 2007 WORKS. Note
that Spring 0.75b2 depends on the boost libraries version 1.34.* and won't
work on lower versions. (updated libboost-serialization-dev, and libvorbis-dev dependencies for 0.76b1)


Also, on 64-bit be sure to build against devIl 1.6.8-rc2 or higher, 1.6.7 has a bug in the PNG loading code that causes issues.
== Gentoo ==
This has been tested to work with a clean install of gentoo 2008.0:


<code><pre>
<pre>
sudo aptitude install scons build-essential zlib1g-dev libfreetype6-dev
emerge cmake \>=media-libs/freetype-2.0.0 \>=media-libs/libsdl-2
sudo aptitude install libsdl1.2-dev libopenal-dev libglew-dev libboost-dev
emerge media-libs/openal media-libs/glew dev-libs/boost
sudo aptitude install libboost-thread-dev libboost-regex-dev libdevil-dev
emerge app-arch/zip media-libs/libogg
sudo aptitude install libboost-serialization-dev python2.5-dev zip
USE="png jpg tiff opengl" emerge media-libs/devil
sudo aptitude install sun-java6-jdk libvorbis-dev libxcursor-dev
</pre>
</pre></code>


==== Gentoo ====
Or better you install Spring via [http://springrts.com/wiki/Gentoo_install layman], it will install all dependencies.
This has been tested to work with a clean install of gentoo 2007.0:


<code><pre>
== Fedora ==
emerge dev-util/scons \>=media-libs/freetype-2.0.0 \>=media-libs/libsdl-1.2.0
emerge media-libs/openal =dev-lang/python-2.4\* media-libs/glew dev-libs/boost
emerge media-libs/devil app-arch/zip media-libs/libogg
</pre></code>


==== Fedora ====
On Fedora 31:


On Fedora 8, these dependencies should be sufficient:
<pre>
sudo dnf install gcc-c++ cmake boost-devel DevIL-devel freetype-devel libunwind-devel \
glew-devel libvorbis-devel libXcursor-devel openal-devel SDL2-devel p7zip jsoncpp-devel
</pre>


<code><pre>
== Slackware ==
yum install scons boost-devel openal-devel SDL-devel \
DevIL-devel glew-devel java-1.7.0-icedtea-devel libvorbis-devel
</pre></code>


=== Build And Install ===
On Slackware 13, cmake, ogg & vorbis, boost, glew and SDL2 already come with the full regular install, both libs and headers. You can find helper scripts to easily compile and package DevIL, OpenAL and spring itself [http://slackbuilds.org/ here].


The build will spew out warnings like the following, which you can safely ignore:
Try to use [http://idlemoor.github.io/slackrepo/ slackrepo], will search, update and install spring and dependences.


<code><pre>
= Build And Install =
warning: division by zero
warning: 'q' may be used uninitialized in this function
</pre></code>


== Using CMake (2.6 or newer) ==
Configure and build:
Configure and build:


<code><pre>
<pre>
scons configure
cmake .
scons
make spring
</pre></code>
</pre>


Install:
Install:


<code><pre>
<pre>
scons install
make install-spring
mkdir -p /etc/spring
</pre>
echo '$HOME/.spring' > /etc/spring/datadir
 
</pre></code>
 
Default install paths are:
 
<code>/usr/local/bin/spring</code> Spring executable
 
<code>/usr/local/share/games/spring</code> read-only data
 
If you want <code>~/spring</code> prefix instead of <code>/usr/local</code>, configure like this:
 
<pre>
cmake -DCMAKE_INSTALL_PREFIX=~/spring .
</pre>
For further ways of customizing your build, have a look at the variables shown with:
<pre>
cmake -LH .
</pre>
 


Your paths are: Spring executable in <code>/usr/local/games/spring</code> and
For other targets see the output of <code>make help</code>.
read-only data in <code>/usr/local/share/games/spring</code>.


{{Finalizing_linux_install}}
= See Also: =
* [[Finalizing_linux_install]]
* [[Troubleshooting_linux]]


{{Linux_tips}}


{{Troubleshooting_linux}}
[[Category:Compiling]]
[[Category:Linux]]

Latest revision as of 08:42, 11 May 2020

Development < Building Spring < Building Spring on Linux

Build From Source on Linux

If you prefer to use your distributions package system (release versions only), refer to the Linux SetupGuide.

If there is no package tailored for your distribution, you have to install from sources manually. Doing this for distributions where packages are available is not recommended.

Warning:
Be careful when building from source.
You might encounter sync errors in online play if:

  • you are using an untested compiler (gcc from the >=4.6 series should be safe)
  • you use non-standard compiler settings (be careful about -march)!

Obtaining the Source

Tarballs

(For playing online official games on lobby.springrts.com - the spring lobby server)

Using Git is the recommended way to get the sources of the engine. In spite of, you can use the official tarballs to compile Spring without git.

Note: Do NOT use the zip-files from github, they are missing important data to compile Spring.

See Building spring for build instructions.

Git

Spring project page at github

Master repo URI: git://github.com/spring/spring.git
Backup repo: git://git.code.sf.net/p/springrts/code

Branches of interest:

  • master - latest stable, enforced for official games on lobby.springrts.com
  • maintenance - fixes for the latest stable
  • develop - major developments (most active, larger developments)

Assuming the GIT command line client is installed, you can clone (get locally) the repository with the commands below.

Latest Stable (master branch, useless for development purposes, lives as maintenance moving forward)

git clone --recursive git://github.com/spring/spring.git -b master

To later update it (get the changes other people did) with:

git pull --rebase

Maintenance (maintenance branch)

git clone --recursive git://github.com/spring/spring.git -b maintenance

Bleeding-edge (develop branch)

git clone --recursive git://github.com/spring/spring.git -b develop

Working with git

Please note that patches to the code must be done for either develop or maintenance. Such patches can be then sent to one of the developers with repository access. If you are new to git and github, you may want to have a look at this guide to get you started.

Note: you can switch branches this way:<syntaxhighlight lang="bash">

  1. (optional) backup your current code changes

git stash

  1. switch branch

git checkout $MY_OTHER_BRANCH

  1. sometimes needed
  2. note, it deletes all your unstashed changes and all non-pushed commits on the new branch,
  3. but it doesn't delete untracked files.
  4. git reset --hard
  1. update/sync with remote repo

git pull --rebase

  1. (optional) if you want to apply the code changes backed-up in the first step
  2. git stash pop # reapplies your changes and DELETES the backup
  3. or
  4. git stash apply --index 0 # reapplies your changes and keep the backup (see `git stash list`)

</syntaxhighlight>

Submodules

To obtain the submodules you should clone the repository with --recursive as mentioned above. If you haven't done this, you can execute the following code <syntaxhighlight lang="bash"> git submodule sync git submodule update --init

</syntaxhighlight>

To update the submodules, you have to execute the same commands again or pull normally.

Get Dependencies

To compile, you will have to install some development packages Spring depends on. These vary from distro to distro and may also depend on your specific configuration.

If your distributions is not listed below, you should be able to figure out the correct package names from this.

Full list

  • Programs necessary to build
    • cmake
    • 7zip (aka p7zip or 7z)
    • The usual build toolchain
      • gcc
      • make
  • Libraries
    • SDL2
    • libdeviL (IL)
    • OpenAL (openal-soft, older openal-0.0.8 does not work)
    • OpenGL headers (mesa, GLEW, etc.)
    • zlib
    • freetype (2)
    • ogg, vorbis and vorbisfile
    • curl
  • Optional (for AI Interfaces, Skirmish AIs and unit tests)
    • python (2.5+)
    • jdk (1.5+)
    • boost (version 1.47 or later)
      • chrono
      • filesystem
      • threads
      • system
      • chrono

Debian

For Jessie (debian 8.0 stable) this should work:

sudo apt-get install build-essential zlib1g-dev libfreetype6-dev cmake \
libsdl2-dev libopenal-dev libglew-dev zip libvorbis-dev libxcursor-dev \
libdevil-dev libboost-system1.55-dev libboost-thread1.55-dev \
libboost-regex1.55-dev libboost-serialization1.55-dev \
libboost-program-options1.55-dev libboost-chrono1.55-dev \
libunwind-dev  libboost-filesystem1.55-dev \
libboost-signals1.55-dev libboost-test1.55-dev \
xsltproc libfontconfig1-dev libcurl4-openssl-dev


Ubuntu

# compiler and build tools
sudo apt-get install build-essential cmake cmake-gui git 

# spring dependencies
sudo apt-get install libglew-dev libsdl2-dev libdevil-dev libopenal-dev \
 libogg-dev libvorbis-dev libfreetype6-dev p7zip-full libxcursor-dev \
 libboost-thread-dev libboost-regex-dev libboost-system-dev \
 libboost-program-options-dev libboost-signals-dev \
 libboost-chrono-dev libboost-filesystem-dev libunwind8-dev \
 default-jdk libcurl4-gnutls-dev

to speed up compiling/linking, you can install gold, an alternative linker and when you plan to develop / recompile often ccache :

sudo apt-get install binutils-gold ccache


to make ccache useful, the cache size needs to be increased by:

ccache -M 5G

to set it to 5GB.

Gentoo

This has been tested to work with a clean install of gentoo 2008.0:

emerge cmake \>=media-libs/freetype-2.0.0 \>=media-libs/libsdl-2
emerge media-libs/openal media-libs/glew dev-libs/boost
emerge app-arch/zip media-libs/libogg
USE="png jpg tiff opengl" emerge media-libs/devil 

Or better you install Spring via layman, it will install all dependencies.

Fedora

On Fedora 31:

sudo dnf install gcc-c++ cmake boost-devel DevIL-devel freetype-devel libunwind-devel \
glew-devel libvorbis-devel libXcursor-devel openal-devel SDL2-devel p7zip jsoncpp-devel

Slackware

On Slackware 13, cmake, ogg & vorbis, boost, glew and SDL2 already come with the full regular install, both libs and headers. You can find helper scripts to easily compile and package DevIL, OpenAL and spring itself here.

Try to use slackrepo, will search, update and install spring and dependences.

Build And Install

Using CMake (2.6 or newer)

Configure and build:

cmake .
make spring

Install:

make install-spring


Default install paths are:

/usr/local/bin/spring Spring executable

/usr/local/share/games/spring read-only data

If you want ~/spring prefix instead of /usr/local, configure like this:

cmake -DCMAKE_INSTALL_PREFIX=~/spring .

For further ways of customizing your build, have a look at the variables shown with:

cmake -LH .


For other targets see the output of make help.

See Also: