Building Spring on MacOSX: Difference between revisions

From Spring
Jump to navigationJump to search
Hoijui (talk | contribs)
Hoijui (talk | contribs)
Line 115: Line 115:
==Removing duplicate libraries==
==Removing duplicate libraries==


Make sure that you remove all extra libraries before the first time you call cmake.  If not, cmake will make your life a living hell.  Check in /usr /usr/local /opt/local and /Library/Frameworks.  Also, don't change the location of the source directory, librarys, or includes after calling cmake.  If you do change any of the locations you can't just call cmake again.  The only way I know to tell it to recompute everything from scratch is this:
Make sure that you remove all extra libraries before the first time you call ''cmake''.  If not, ''cmake'' will make your life a living hell.  Check in ''/usr'', ''/usr/local'', ''/opt/local'' and ''/Library/Frameworks''.  Also, do not change the location of the source directory, librarys, or includes after calling ''cmake''.  If you do change any of the locations you can not just call ''cmake'' again.  The only way I know to tell it to recompute everything from scratch is this:
*Change to the root of the git tree
 
*Remove every single visible file.
* Change to the root of the source tree
*Run git reset --hard
* Remove every single visible file (NOT the ''.git/'' dir)
* Run <code>git reset --hard</code>


==Using CMake (2.6 or newer) (Adso's method)==
==Using CMake (2.6 or newer) (Adso's method)==

Revision as of 15:28, 16 June 2010

Development < Building Spring < Building Spring on MacOSX

Duplicate and missing information

This page is a partial duplicate of Spring_on_MacOSX but both have unique information.


Build from source on MacOSX

Guide is for x86/Intel based OSX 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!

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.

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

You will need to install some development packages Spring depends on. Most of these are available using Macports (similar to portage / apt-get etc available on various linux distro's)

You will also need to install the Xcode developers package (this requires a free membership to apple's ADC website)

Full list

  • Programs necessary to build
    • Xcode
    • cmake (or scons)
    • zip
    • The usual build toolchain
      • gcc (comes with Xcode tools)
      • make (comes with Xcode tools)
  • Libraries
    • SDL
    • boost (version 1.35 or later recommended)
      • threads
      • regex
      • signals
      • system
    • DeviL (IL, ILU)
    • OpenAL Please check the OpenAL section for MacOSX specific info
    • OpenGL headers (mesa, glew, etc.) (comes with Xcode tools)
    • zlib
    • freetype
    • ogg,vorbis and vorbisfile
  • Optional, for bindings and Ais
    • Python (2.5)
    • Java-SDK (pre-installed on OSX)

Using Macports

Once you have downloaded and configured Macports use these commands to download / compile and install the required dependencies :

sudo port install cmake
sudo port install libsdl
sudo port install libsdl-framework
sudo port install boost
sudo port install boost-jam
sudo port install libpng #These image libraries might not be needed, but ma save you some headaches
sudo port install jpeg
sudo port install tiff
sudo port install libogg
sudo port install libvorbis
sudo port install python25
sudo port install libdevil # as of October 12th 2009 the Macports install of libdevil (1.6.8-rc2_0) is broken for some people. If you get errors like /opt/local/include/IL/il.h:505: error: ‘<anonymous>’ has incomplete type while building spring, you'll probably need to install it from source. )

If all was successful, you are very close to being able to compile Spring naively!

Installing libdevil from source

Make sure that all the other port packages are installed first! Download the source. Right now 1.6.8-rc2_0 has the bug we're trying to work around, so don't use that one, or earlier versions.

Extract the source code.

Configure it. I used this command. ./configure --enable-png --enable-ILU --enable-ILUT --enable-x86_64 CPPFLAGS="-I/opt/local/include/ -L/opt/local/lib/" LDFLAGS=-L/opt/local/lib/

Make sure you have support for png, jpg, dds, and tga

Make it with "make"


Part way through you'll get an error about malloc.h not being found. To fix it, replace <malloc.h> with <sys/malloc.h>

install with sudo make install


OpenAL

After having mountains of problems myself with the OpenAL pre-installed with the Xcode tools, I discovered that it is version 1.0 of OpenAL (not the correct version we want).

Head to your /System/Library/Framework/ folder and delete any trace of OpenAL framework / folders that are there.

Now download this copy of OpenAL

Using the terminal, go into the folder where you downloaded openal-soft and pass these commands

bzip2 -d openal-soft-xxxx.tar.bz2 | tar xvf -
cd openal-soft-xxxx
cmake .
make
make install

All done, now you will have no problems compiling the Sound.cpp file in spring!

Build And Install

The build will spew out warnings like the following, which you can safely ignore:
warning: division by zero
warning: 'q' may be used uninitialized in this function

Removing duplicate libraries

Make sure that you remove all extra libraries before the first time you call cmake. If not, cmake will make your life a living hell. Check in /usr, /usr/local, /opt/local and /Library/Frameworks. Also, do not change the location of the source directory, librarys, or includes after calling cmake. If you do change any of the locations you can not just call cmake again. The only way I know to tell it to recompute everything from scratch is this:

  • Change to the root of the source tree
  • Remove every single visible file (NOT the .git/ dir)
  • Run git reset --hard

Using CMake (2.6 or newer) (Adso's method)

This is the only way I have compiled spring successfully so far:

(could someone please add a better way? As I cannot workout how to get xcodebuild to run the "install portion of the make file")

cmake .
make spring
make install-spring

This will install spring in all the right places to be run from a command line (but don't yet, it compiles an unusable executable, we just needed to get the makefile to install everything to the right place)

Now pass these commands

cmake -G Xcode
xcodebuild

This will have made a folder called "Debug" and will contain a command line program Spring, and Libunitsync.dylib

now to make sure the correct copy of spring runs when you are using the terminal pass the following command

sudo cp spring /usr/local/bin

Now you are ready to ready to play Spring on your MacOSX system! Enjoy!

Using CMake (2.6 or newer) (patmo98's method)

The worst problem I ran into while trying to use Adso's method was getting the include and library paths to work. This probably won't be needed unless you you been installing libraries from source or using fink.

Make sure before you start that you don't have any extra copies of libraries laying around.

Get the dependencies and source code.

ccmake .

If you see a list of options here, you've already run (c)cmake before and that may cause you trouble. Press c to have it auto configure. Press t to switch to advanced mode. Manually add the following includes and librarys. Yes, this is an ugly hack that should be instead fixed in the build system, but I don't know enough about cmake to fix it.

CMAKE_CXX_FLAGS                  -I/usr/local/include -I/opt/local/include
CMAKE_C_FLAGS                    -I/usr/local/include -I/opt/local/include
CMAKE_EXE_LINKER_FLAGS           -L/usr/local/lib -L/opt/local/lib

You may need to add more directories.

Now you can compile:

make spring

If the build finishes successfully, you will now have the spring executable, unitsync.dylib, and some other assorted things.

Spring will search for Libunitsync.dylib in the same directory as the executable (and possibly other places), and search for the data files in ~/.spring/. If you have access to a working windows install, just copy the windows install to ~/.spring/ and run the executable from where ever you like.


Now you are ready to play Spring on your Mac OS X system! Enjoy!

Finalizing installation

Will update later once I update the Springlobby wiki with all my OSX information!

If you need to contact me, send a PM to adso on the forums, or catch me in #sy or #springlobby in the lobby chat :)

--Adso 06:23, 29 August 2009 (UTC)