Building Spring on Windows: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
Flozi (talk | contribs)
Line 21: Line 21:


minimum packages:
minimum packages:
* MinGW Runtime - ''mingwrt (dev & dll. version 3.17, 3.18+ will cause a "multiple definition of _tls_used" linker error)''
* MinGW Runtime - ''mingwrt (dev & dll. version 3.17 reccomended, 3.18+ will cause a "multiple definition of _tls_used" linker error)''
* MinGW API for MS-Windows - ''w32api (dev)''
* MinGW API for MS-Windows - ''w32api (dev)''
* GNU Binutils - ''binutils (bin)''
* GNU Binutils - ''binutils (bin)''

Revision as of 20:48, 6 June 2010

Development < Building Spring < Building Spring on Windows

Get the Source Code

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.

Compiling on Windows

For other platforms see Building spring.

Install MinGW

Code::Blocks and Dev C++ use MinGW too, so if you are using one of these IDEs, you'll want to follow these instructions too.

Getting MinGW

Compiling Spring in MinGW requires GCC 4.x There are 2 different packages the official one and the TDM (experimental) builds.

Official 4.4.0 (recommended)

(Note: you can't override an existing old TDM enviroment with these, you first have to uninstall TDM, else you will get some "undefined ... SJLJ_xyz" linking errors!)

Get it here: official MinGW

You have to get MinGW as a bunch of separate packages, as the downloader does not support installing gcc 4.4.0 yet, which is needed to compile spring successfully.

minimum packages:

  • MinGW Runtime - mingwrt (dev & dll. version 3.17 reccomended, 3.18+ will cause a "multiple definition of _tls_used" linker error)
  • MinGW API for MS-Windows - w32api (dev)
  • GNU Binutils - binutils (bin)
  • GCC 4 - gcc-core (bin & dll)
  • GCC 4 - gcc-c++ (bin & dll)
  • GCC 4 - pthreads (dll)
  • GCC 4 - mpfr (dll)
  • GCC 4 - gmp (dll)

instead of the five above mentioned GCC packages (17MB), you could also get it in a single archive instead (60MB):

  • GCC 4 - full (bin)

if you do not have an other make system in place, get this in addition:

  • GNU Make - mingw32-make

if you want to debug, you will want this as well:

  • GNU Source-Level Debugger - gdb (version 6.8-3 or later)

Extract all the packages to a common dir, eg. C:/MinGW/, and then the environment vars:

  • MINGDIR=C:/MinGW
  • PATH=%PATH%;%MINGDIR%\bin

You also need some Spring dependencies, prepackaged in the mingwlibs archive.

You can get it here (Download Source button, or use git):

(Note: TDM builds need a different package!)

TDM Builds (alternative)

Get it here: TDM's experimental MinGW

Get at least the following packages:

  • mingw-runtime
  • core
  • c++
  • binutils
  • win32api

In the case you use the old SJLJ exception handling you need this: v19 of the MinGW library package. If you use the new Dwarf2 handling use the mingwlibs package for the official GCC from above.

MinGW Setup

There are two ways to setup the MinGL libraries:

1. Make sure you install the package in the checkout directory, so the path is: /spring/mingwlibs. If done right, it will look like:

  • /spring/
  • /spring/installer
  • /spring/rts
  • /spring/... other dirs
  • /spring/mingwlibs

2. Install the package somewhere else (preferably outside of the source tree), and pass its location with the MINGDIR option to CMake in the configure step (see further down, in the quick instructions).

These programs are a must have if you want to compile Spring with MinGW, so install them now, if you don't have them already.

Compiling with cmake

Currently the CMake scripts are not capable of generating Visual Studio project files, so CMake can only be used for gcc compiling.

  • run the cmake-gui and select a source and a build directory
  • configure and follow the instructions, and adjust variables to your needs (defaults are OK)
  • press generate
  • open a console, cd into your build directory, run "mingw32-make"

Compiling with scons

Install the following programs (you don'T need cmake in this case):

Quick instructions

  • Grab and install the above programs.
  • Make sure C:\Python25, C:\Python25\Scripts and C:\Dev-Cpp\bin are in your PATH environment variable. Set environment variables by: Start -> Settings -> Control Panel -> System -> Advanced -> Environment variables (for Windows XP).
  • Make sure a MINGDIR environment variable with value C:\Dev-Cpp exists. (change paths where appropriate.)
  • Checkout the Spring SVN repository, following the instructions above in obtaining source. (TODO:link)
  • Open a console (Start -> Run -> cmd.exe -> Run), cd \where you checked it out in the previous step, if you checked it out on a different drive make sure to change drives with DriveLetter:<enter> first.
  • Type scons configure<enter>. Refer to scons --help for options which can be passed to scons configure. Gotchas:
    • If you get an error message starting with "EOFError: : env = Environment...", try deleting the file build/scons_signatures.dblite
    • If you get an error message stating "ImportError: No module named win32file:", you have probably not installed the python-win32-extensions.
    • If all proceeds as intended you will see a message similar to: "Everything seems OK. Run `scons' now to build."
  • Type scons<enter> to start the compilation.
    • If you have Delphi installed and get an error message that the commandline params "--no-print-directory" & "-C" aren't supported, then you should remove the Delphi dirs from your PATH variable, because scons tried to run the delphi's make.exe instead of using mingw32-make. (this will cause that streflop can't be build!)
  • Wait for the compilation to finish, this may take a while.
  • Copy datafiles and stuff from official Spring installation to the /spring/game directory (where spring.exe is located, after the compilation finished.)
  • Copy missing DLLs from mingwlibs/dll.
  • Start developing.

Visual Studio 8 (2005)

(possibly the free Express Edition)

  • Install the vclibs library package. You need to install this in the /spring directory from the SVN checkout or the zipped source. If done right, it will look like:
    • /spring/
    • /spring/installer
    • /spring/rts
    • /spring/... other dirs
    • /spring/vclibs
  • Install the DirectX SDK
  • Install the PlatformSDK. I got away with unchecking the parts of the PlatformSDK that were obviously not related (IIS, web stuff). Makes for a smaller download. Make sure the Platform SDK and DirectX SDK are in the VS search/include directories.
    • Note that the most recent version of Platform SDK is called Windows SDK.
  • After installing them, open Visual C++. Click Tools >> Options >> Projects and Solutions >> VC++ Directories. Add these entries to the corresponding sections (paths just a reference, yours may be different):
    • Include files:
      • $(ProgramFiles)\Microsoft DirectX SDK (August 2007)\Include
      • $(ProgramFiles)\Microsoft Platform SDK\include
    • Library files:
      • $(ProgramFiles)\Microsoft DirectX SDK (August 2007)\Lib\x86 (Might need \x64 on a 64-bit platform, I don't know.)
      • $(ProgramFiles)\Microsoft Platform SDK\lib
  • Open the solution. /spring/rts/build/vstudio8/rts.sln
  • Start building (usually you want to select the release/no debug build, debug is really too slow and is used only when you really know what you want to test)
  • Select the working directory in the project properties, otherwise spring will not work correctly

Errors

  • ...\Windows\v6.0A\include\shlwapi.h(196) : error C2061: syntax error : identifier 'PCUITEMID_CHILD' - wrong version of Platform SDK is used; go to Tools >> Options >> >> Projects and Solutions >> VC++ Directories and move the one that's causing this problem all the way down.

Visual Studio 9 (2008)

(possibly the free Express Edition)

Not yet fully working as far as I know; you need at least this hotfix from Microsoft though:

http://support.microsoft.com/kb/946040

or update your Visual Studio using your Windows Update.

For the rest the Visual Studio 8 instructions should apply, mostly. You probably won't need to add Windows SDK path references as they should be present by default.

You need the vclibs for VS2008, and not the ones for Visual Studio 2005. The installation procedure is the same though.

Be aware that the project file isn't updated nearly as frequently as it should, so it's best to use the .vcproj file from VS8 build and VS2008 will automatically update it.

General Visual Studio Notes

So far the following aspects of Spring don't function properly or don't function at all when compiled with Visual Studio:

  • Your VS build won't sync with GCC builds in multiplayer mode (currently being worked at)
  • Any external AI crashes immediatley at start, LUA AI works though