Building Spring on Windows: Difference between revisions
| Line 22: | Line 22: | ||
Get at least the following packages: | Get at least the following packages: | ||
* gcc (version <u> | * gcc (version <u>dw2/dwarf2</u>!) | ||
** core | ** core | ||
** g++ | ** g++ | ||
Revision as of 00:15, 5 May 2011
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
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">
- (optional) backup your current code changes
git stash
- switch branch
git checkout $MY_OTHER_BRANCH
- sometimes needed
- note, it deletes all your unstashed changes and all non-pushed commits on the new branch,
- but it doesn't delete untracked files.
- git reset --hard
- update/sync with remote repo
git pull --rebase
- (optional) if you want to apply the code changes backed-up in the first step
- git stash pop # reapplies your changes and DELETES the backup
- or
- 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.
Essential Tools and Libraries
If you are new to programming for open-source projects on Windows you'll quickly discover it can often be difficult to find the right software and dependencies. To aid you in your journey you will find stable versions of most of the tools and libraries listed below on this mirror. Use them if you have trouble finding what you need below.
If you have trouble opening any of the archives please install the application 7zip as it supports all of the archive formats in common use (it's in the tools/archiving subdirectory).
Compiling on Windows
For other platforms see Building spring.
Install MinGW
Compiling Spring in MinGW requires GCC 4.x
Because the official MinGW installer & packages are totally outdated and abandoned, we recommend to use the TDM ones instead:
TDM webinstaller
Get it here: TDM-MinGW (download the webinstaller alias "On-Demand Installer")
Get at least the following packages:
- gcc (version dw2/dwarf2!)
- core
- g++
- binutils
- mingw-runtime
- win32api
- gdb (recommended for debugging)
- openmp (optional)
If you get undefined ... _Unwind_Resume linking errors, deinstall whole TDM/MinGW and reinstall it with dwarf2.
When using dwarf2 as suggested, the compilers will be named abc-dw2. Rename (atleast) these two, or CMake will fail:
- "C:/MinGW32/bin/gcc-dw2.exe" to "gcc.exe"
- "C:/MinGW32/bin/g++-dw2.exe" to "g++.exe"
Since building Spring depends on the tool dos2unix, not provided by TDM, add cygutils-dos2unix from https://sourceforge.net/projects/mingw/files/MinGW/cygutils/, and libpopt(dll) from https://sourceforge.net/projects/mingw/files/MinGW/popt/
Spring MinGW Dependencies (mingwlibs)
You also need some Spring dependencies, prepackaged in the mingwlibs archive.
You can download a tarball here (Download Source button).
Or (recommended) use git:
- open a console (cmd.exe) or use git's bash (you find it in the right click context menu when clicking the folder),
cdinto your source dir - make a dir named mingwlibs
cd mingwlibs- run
git clone git://github.com/spring/mingwlibs.git - and update it from time to time with:
git pull --rebase
mingwlibs install directory
There are two ways to setup the MinGW libraries:
- 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/...
- */spring/mingwlibs
- */spring/rts
- 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).
Compiling with cmake
First get CMake here and install it.
then
- 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 (cmd.exe), cd into your build directory
- optional: for multi-threaded compilation, the mingw32-make part may differ on your system:
set MAKE_COMMAND=mingw32-make -j2
- compile with:
mingw32-make install-spring
Compiling with scons
deprecated - use cmake
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
- Include files:
- 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
- Any external AI crashes immediatley at start, LUA AI works though