Building Spring on MacOSX: Difference between revisions

From Spring
Jump to navigationJump to search
m In macports download: changed libsdl -> libsdl2
Rewrite the guide to (hopefully) be cleaner, and (definitely) be more up-to-date
Line 1: Line 1:
[[Engine_Development|Development]] < [[Building_spring|Building Spring]] < {{FULLPAGENAME}}
[[Engine_Development|Development]] < [[Building_spring|Building Spring]] < {{FULLPAGENAME}}


If you want only to play a spring game, follow the [[Spring_on_MacOSX]] Tutorial.
This is a guide to the requirements for building the Spring RTS engine on MacOS. If you want only to play a spring game, follow the [[Spring_on_MacOSX]] Tutorial.




=Build from source on MacOSX=
=Building Spring on MacOS=


'''Guide is for x86/Intel based OSX installs'''
'''Guide is for x86/Intel based MacOS installs'''


I am hoping that with our efforts on the forum that we can have an .app bundle released everytime spring is updated and that will save most people needing to go through the headache of compiling from source code. But if you must try, then here's the steps to help!
Even though it will not run, Spring should successfully compile on Mac for both 104.0 and the latest develop version.


I cannot stress enough that this will most likely only work on Intel based systems at this stage. With my understanding of how unitsync works, it seems like online play will not be possible between PPC and x86 architecture.
NOTE: Only official spring versions 99.0-103.1 will compile and run on MacOS. 104+ will compile, but uses an incompatible OpenGL version. When 105.0 is released, a MacOS - compatible OpenGL version will be used, however at this point in time '''there are other blocking issues'''.


=Get Dependencies=
Questions about this process should be asked [https://springrts.com/phpbb/viewforum.php?f=65 here].


Install the [http://developer.apple.com/TOOLS/Xcode/ Xcode developers package] (this requires a free membership to apple's ADC website) and  [http://www.macports.org/install.php mac ports] or [http://brew.sh homebrew].




=Requirements=


==Using Macports==
==Command Line Tools==
Install the [http://developer.apple.com/TOOLS/Xcode/ Xcode developers package] (this requires a free membership to apple's ADC website).
 
==Package Manager==
Either  [http://brew.sh Homebrew] or [http://www.macports.org/install.php MacPorts] may be used to fetch dependencies. The MacOS Buildbot (run by Turboss) uses Homebrew. The writer uses Macports.
 
== Compiler==
 
Compiler: GCC must be used, and dependencies must be compiled with GCC
 
For MacPorts:
<code><pre>
port install
sudo port select --set gcc mp-gcc8
hash -r # Reload the terminal
</pre></code>


As hint: set "buildmakejobs" to cpu-core count + 1 in /opt/local/etc/macports/macports.conf. For example:
To check for installed gcc:
<code><pre>
<code><pre>
buildmakejobs 5
port select --list gcc
</pre></code>
</pre></code>


Once you have downloaded and configured Macports use these commands to download /
==Dependencies==
compile and install gcc:
 
Necessary dependencies for the develop branch are below (as called by Macports):


<code><pre>
<code><pre>
sudo port install gcc48
port install sudo port install cmake libsdl2 p7zip libdevil libvorbis minizip openal-soft glew freetype binutils libXcursor +gcc8
</pre></code>
</pre></code>


now select the installed gcc as default:
(This list has not been tested for errors; please message MasterBel if they do not work for you.)
 
Compiling Spring 104.0 (current master) or older will also require Boost. [https://sourceforge.net/projects/boost/ Retreive source] and compile with gcc. '''TODO: Instructions?'''
 
==Obtaining Source==
 
git clone --recursive git://github.com/spring/spring.git -b <branch>
 
<code><pre>
<code><pre>
sudo port select --set gcc mp-gcc48
The “master” branch is the latest stable release. “develop” branch is the latest development release
hash -r
</pre></code>
</pre></code>


if you don't know the installed gcc, type:
The recursive argument is important for submodules. Update with:
 
<code><pre>
<code><pre>
port select --list gcc
git pull --rebase
</pre></code>
</pre></code>


and now the required dependencies:
=Compiling Source=
 
<code><pre>
<code><pre>
sudo port install cmake libsdl2 boost libpng jpeg \
cmake . -DCMAKE_CXX_COMPILER=$MACPORTS/bin/g++-mp-8 -DCMAKE_C_COMPILER=$MACPORTS/bin/gcc-mp-8
                  tiff libogg libvorbis python27 libdevil git-core binutils \
make spring
                  openal p7zip glew freetype +gcc48
</pre></code>
</pre></code>
binutils are required because of "addr2line", this allows finding bugs.


If all was successful, you are very close to being able to compile Spring naively!
Other common Cmake flags are:
<code><pre>
-DGLEW_INCLUDE_DIR=/path/to/include -DGLEW_LIBRARIES=/path/to/lib/libGLEW.a -DOPENAL_INCLUDE_DIR=/path/to/include/AL -DCMAKE_INSTALL_PREFIX:PATH=/path/to/output/directory
</pre></code>


==Using Homebrew==
If boost is used:
WIP
<code><pre>
<code><pre>
brew install sdl2    sdl2_gfx sdl2_image  sdl2_mixer sdl2_net  \
-DBoost_Root=/path/to/boost
  sdl2_ttf binutils p7zip glew freetype \
-DCMAKE_PREFIX_PATH=$MACPORTS
openal-soft homebrew/versions/gcc48
</pre></code>
</pre></code>
Recompile boost library with gcc 4.8:
 
Number of simultaneous jobs may be specified by:
<code><pre>
<code><pre>
brew install boost --build-from-source --cc=gcc4.8
make spring -j<n>
</pre></code>
</pre></code>
Where n is number of jobs. It is common for n to be number of cores + 1


=Obtaining the Source=
Other targets may be made also/instead, e.g.
{{Obtaining_The_Source_Code}}
 
= Build And Install =
== macports ==
Configure and build:


<code><pre>
<code><pre>
cmake .
make prdownloader -j<n>
make spring
make install-spring -j<n>
</pre></code>
</pre></code>


macports-specific instructions:


=Additional Notes=
==Using Macports==
As hint: set "buildmakejobs" to cpu-core count + 1 in /opt/local/etc/macports/macports.conf. For example:
<code><pre>
<code><pre>
cmake . -DCMAKE_CXX_COMPILER=${prefix}/bin/g++-mp-4.8 -DCMAKE_C_COMPILER=${prefix}/bin/gcc-mp-4.8 \
buildmakejobs 5
-DFREETYPE_INCLUDE_DIR_freetype2=${prefix}/include/freetype2 -DFREETYPE_INCLUDE_DIR_ft2build=${prefix}/include/freetype2 \
-DFREETYPE_LIBRARY=${prefix}/lib/libfreetype.dylib
make spring
</pre></code>
</pre></code>


(optional)
==Using Homebrew==
you can have multiple versions of spring installed - for example, by installing them in a prefix, by adding
 
<code><pre>-DCMAKE_INSTALL_PREFIX:PATH=/path/where/you/want/to/install/it</pre></code>
Hombrew can install boost, but it must be recompiled  with gcc <version>:
after
<code><pre>
<code><pre>
cmake .
brew install boost --build-from-source --cc=gcc<version>
</pre></code>
</pre></code>


for example
Build And Install:
<code><pre>cmake . -DCMAKE_INSTALL_PREFIX:PATH=/opt/spring/96.0 \
-DCMAKE_CXX_COMPILER=${prefix}/bin/g++-mp-4.8 -DCMAKE_C_COMPILER=${prefix}/bin/gcc-mp-4.8 \
-DFREETYPE_INCLUDE_DIR_freetype2=${prefix}/include/freetype2 -DFREETYPE_INCLUDE_DIR_ft2build=${prefix}/include/freetype2 \
-DFREETYPE_LIBRARY=${prefix}/lib/libfreetype.dylib</pre></code>


==brew-specific instructions:==
==brew-specific instructions:==
Line 108: Line 122:
-DOPENAL_DIR=/usr/local/include/AL \
-DOPENAL_DIR=/usr/local/include/AL \
-DNO_SOUND=1
-DNO_SOUND=1
</pre></code>
==Install:==
<code><pre>
make install-spring
</pre></code>
</pre></code>


[[Category:Compiling]]
[[Category:Compiling]]

Revision as of 08:41, 28 December 2018

Development < Building Spring < Building Spring on MacOSX

This is a guide to the requirements for building the Spring RTS engine on MacOS. If you want only to play a spring game, follow the Spring_on_MacOSX Tutorial.


Building Spring on MacOS

Guide is for x86/Intel based MacOS installs

Even though it will not run, Spring should successfully compile on Mac for both 104.0 and the latest develop version.

NOTE: Only official spring versions 99.0-103.1 will compile and run on MacOS. 104+ will compile, but uses an incompatible OpenGL version. When 105.0 is released, a MacOS - compatible OpenGL version will be used, however at this point in time there are other blocking issues.

Questions about this process should be asked here.


Requirements

Command Line Tools

Install the Xcode developers package (this requires a free membership to apple's ADC website).

Package Manager

Either Homebrew or MacPorts may be used to fetch dependencies. The MacOS Buildbot (run by Turboss) uses Homebrew. The writer uses Macports.

Compiler

Compiler: GCC must be used, and dependencies must be compiled with GCC

For MacPorts:

port install
sudo port select --set gcc mp-gcc8
hash -r # Reload the terminal

To check for installed gcc:

port select --list gcc

Dependencies

Necessary dependencies for the develop branch are below (as called by Macports):

port install sudo port install cmake libsdl2 p7zip libdevil libvorbis minizip openal-soft glew freetype binutils libXcursor +gcc8

(This list has not been tested for errors; please message MasterBel if they do not work for you.)

Compiling Spring 104.0 (current master) or older will also require Boost. Retreive source and compile with gcc. TODO: Instructions?

Obtaining Source

git clone --recursive git://github.com/spring/spring.git -b <branch>

The “master” branch is the latest stable release. “develop” branch is the latest development release

The recursive argument is important for submodules. Update with:

git pull --rebase

Compiling Source

cmake . -DCMAKE_CXX_COMPILER=$MACPORTS/bin/g++-mp-8 -DCMAKE_C_COMPILER=$MACPORTS/bin/gcc-mp-8
make spring

Other common Cmake flags are:

-DGLEW_INCLUDE_DIR=/path/to/include -DGLEW_LIBRARIES=/path/to/lib/libGLEW.a -DOPENAL_INCLUDE_DIR=/path/to/include/AL -DCMAKE_INSTALL_PREFIX:PATH=/path/to/output/directory

If boost is used:

-DBoost_Root=/path/to/boost
-DCMAKE_PREFIX_PATH=$MACPORTS 

Number of simultaneous jobs may be specified by:

make spring -j<n>

Where n is number of jobs. It is common for n to be number of cores + 1

Other targets may be made also/instead, e.g.

make prdownloader -j<n>
make install-spring -j<n>


Additional Notes

Using Macports

As hint: set "buildmakejobs" to cpu-core count + 1 in /opt/local/etc/macports/macports.conf. For example:

buildmakejobs 5

Using Homebrew

Hombrew can install boost, but it must be recompiled with gcc <version>:

brew install boost --build-from-source --cc=gcc<version>

Build And Install:

brew-specific instructions:

cmake . -DAPPLE=1 -DCMAKE_CXX_COMPILER=/usr/local/Cellar/gcc48/4.8.3/bin/g++-4.8 \
-DCMAKE_C_COMPILER=/usr/local/Cellar/gcc48/4.8.3/bin/gcc-4.8 \
-DIL_INCLUDE_DIR=/usr/local/include \
-DGLEW_INCLUDE_DIR=/usr/local/include \
-DOPENAL_DIR=/usr/local/include/AL \
-DNO_SOUND=1