Building Spring on Windows
If you only want to produce your own Spring game and not contribute to the core engine, compilation is not necessary. Check out Gamedev:Main.
Warning: Compiling Spring on Windows often causes problems, it is heavily recommended to use Linux for developing the Spring RTS Engine if possible.
Some reasons for this:
- Of the active developers nobody uses windows for developing. So they might not be able to help as effectively as on Linux.
- Setting up a build environment takes a lot more time on windows
- Compiling is often slower on windows
- Compiling on windows is poorly tested (which possibly leads to some random / unknown / weird errors)
That said, if you do wish to use Windows, the best place to get real-time help is the #sy lobby channel, or #sy on IRC.
- 1 Compiling with MinGW
- 2 Get the Source Code
- 3 Compiling with Visual Studio (not officially supported!)
Compiling with MinGW
When installing msysGit you should select the option to "Run Git from the Windows Command Prompt":
This is in order to automatically add Git to PATH making it easy for CMake to find.
Select the following options:
- Version: Any version above 4.8.x should work, 4.9.x+ may not have been tested as thoroughly. In 2020, version 8.1.0 works fine!
- Architecture: i686
- Threads: posix
- Exception: sjlj This is the only setting which needs to be changed from the default
- Build Revision: The latest one
Adding to PATH
Once installed, you should add the MinGW directory to your PATH variable so that Cmake can find the relevant binaries.
- Go to System properties (either via Control Panel\System and Security\System or by right clicking 'Computer' on the desktop), then click 'Advanced System Settings'.
- Click the 'Environment Variables' button at the bottom.
- Find Path in the 'System Variables' scrollbox, add an extra
;to the end and then copy-paste in the MinGW directory (e.g. default is
C:\Program Files (x86)\mingw-w64\i686-4.9.1-posix-sjlj-rt_v3-rev0\mingw32\bin).
- Alternative instructions with images are easy to find online, for example here.
Get the Source Code
- use git's bash (you find it in the right click context menu when clicking the folder),
cdinto your spring source dir
git clone --recursive git://github.com/spring/spring.git -b develop cd spring git clone https://github.com/spring/mingwlibs
- update it from time to time with:
git pull --rebase
- Make sure you install the package in the checkout directory, so the path is: /spring/mingwlibs. If done right, it will look like:
- Note: if you 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).
configure using CMake
Note, as of 2020, cmake-3.10.1-win64-x64.msi from https://cmake.org/files/v3.10/ works, 3.18 has issues detecting zlib.
- run the cmake-gui and select a source and a build directory
- press Configure and follow the instructions
- specify native compilers by entering the paths to gcc.exe and g++.exe from your mingw64-builds directory
- if you wish to build the full portable version (install-spring), then make sure to set the CMAKE_INSTALL_PREFIX as well
- In case of configuration errors make sure AI_TYPES variable is set to NONE (default is ALL). This should remedy the issues press Configure again (Remark: Setting NATIVE works as well (tested in commit 9108cae116))
- This is where you can specify the build type, REL for release, DEBUG for debug build, and RELWITHDEBINFO for a mix
- press Generate
- open a console (cmd.exe), cd into your build directory
- optional: for multi-threaded compilation, the mingw32-make part may differ on your system:
(use -j4 for 4 threads). For codeblocks configure CMAKE_CODEBLOCKS_MAKE_ARGUMENTS as -j4
set MAKE_COMMAND=mingw32-make -j2
- compile with:
- compile just the engine (spring.exe) with:
Generating the AI Sources/Wrappers
you can either build the wrapper:
or generate all sources, in case you don't need the binary:
- If you have successfully compiled but don't have an ingame graphical user interface and no widgets working, you could try downloading and compiling from the maintenance branch instead develop.
git clone --recursive git://github.com/spring/spring.git -b maintenance
- If you get undefined reference to `_Unwind_Resume' linking errors, deinstall whole MinGW and reinstall it with sjlj.
- When you installed an old version of MinGW/TDM and forgot to deinstall it correctly,
g++.exewill be named
g++-dw2.exe. CMake will then fail to find the correct one, first try to deinstall anything mingw related and reinstall everything. If that didn't helped just rename the files. If even that doesn't help open cmake-gui and click the advanced button and set the paths to the correct files yourself (
You can still use Visual Studio 2012 as described below to edit the code. This is very useful because it allows excellent code navigation, and it highlights syntax errors and trivial mistakes before compiling.
For debugging mingw builds, you can aquire a windows build of gdb from http://www.equation.com/servlet/equation.cmd?fa=gdb
To start debugging, copy gdb.exe to your build output directory, and launch it with gdb spring.exe. You can supply command line arguments to spring.exe with gdb --args spring.exe myreplayfile.sdf
Compiling with Visual Studio (not officially supported!)
Currently Visual Studio lacks some c++ features it doesn't compile spring!
General Visual Studio Notes
When developing using Visual Studio keep in mind:
- It's experimental and not proved to compile or run!
- Your VS build won't sync with GCC builds in multiplayer mode
- AIs built with Visual Studio will work with the mingw32 release builds thanks to the C AI Interface, however this interface may change when newer releases are made
- Running any non-LUA AI on VS built Spring will crash it
From the Startmenu run "VS2012 x86 Native Tools Command Prompt" and type:
set PATH=%PATH%;%PROGRAMFILES%\git\bin;%PROGRAMFILES%\cmake 2.8\bin\ git clone --recursive git://github.com/spring/spring.git -b develop cd spring git clone git://github.com/spring/vclibs11.git vclibs cmake -G "Visual Studio 11" .
Now start visual studio & open Spring.sln. Select "engine-legacy" as default project, as AIs and ofter stuff are known to fail to compile on visual studio.
In the Project Properties, make sure to select the Microsoft Visual C++ Compiler Nov 2012 CTP.
Note: Visual Studio 2012 Express for Windows Desktop is for free, but requires a registration after 30 days (to get a free license).