HowTo Setup a build environment under windows using Visual Studio 2008¶
In these instructions I do assume you have at least some limited experience with Visual Studio; this is not ment as a Visual Studio tutorial.
Download the necessary tools¶
- Visual C++ 2008 Express Edition is the free, downloadable version of Visual C++. Download this if you do not own a copy of one of the paid editions.
- MsysGit is a fork of git for windows. Download the first file in the list.
- 7-Zip (or a compatible extractor) is an open source file archiver with a high compression ratio.
- wxPack is a precompiled version of wxWidgets so that you don't have to compile it yourself. It also comes with wxFormBuilder. NOTE: With visual studio 2008 you might get issues with the wxPack libraries. In that case you should download the official wxWidgets source release and build them yourself. It is actually quite quick and painless.
- Boost consulting has a precompiled version of boost; it is only necessary to download this if you wish to build SpringLobby with libtorrent (integrated content downloading) support..
- SDL is necessary for sound support. Download the precompiled development libraries for visual studio (at the time of writing the newest version is SDL-devel-1.2.13-VC8.zip )
- SDL_mixer is another lib necessary for sound support. Again, you should download the precompiled development libraries (at the time of writing the newest version is SDL_mixer-devel-1.2.8-VC8.zip )
Dependencies¶
wxWidgets/wxPack¶
CMAKE looks for the wxWidgets libraries in the default installation locations, so accept the path the installer suggests.
Boost¶
Like with wxWidgets, CMAKE looks in the default installation locations. Minimum supported version is 1.35.
SDL and SDL_mixer¶
Extract the SDL zipfile somewhere convenient. Then extract the contents of the SDL_mixer zipfile into the SDL folder so that the SDL_mixer include file end up in the SDL include folder and the SDL_mxier lib and dll files end up in the SDL lib folder.
Since SDL doesn't have a default location on windows you will have to manually configure the four SDL variables in the CMAKE gui.
- SDLMAIN_LIBRARY C:\libSDL\lib\SDLmain.lib
- SDLMIXER_LIBRARY C:\libSDL\lib\SDL_mixer.lib
- SDL_LIBRARY C:\libSDL\lib\SDL.lib
- SDL_INCLUDE_DIR C:\libSDL\include
Git¶
Open up the command prompt (start -> run -> type in cmd -> press ok). Go to the directory where you want the SpringLobby source to be downloaded to. (e.g. C:/ if you want it in C:/springlobby). Find out who's git repository you want to download from (You can find a list of the repositories here.).
Now type:
git clone git://springlobby.info/git/buildbot/springlobby.git
Change the URL with the URL of the Repository you are downloading from.
Line endings
One issue with Git on Windows is it's crappy support for multiple types of line endings. At the time of this writing, msysgit comes with the setting core.autocrlf = true. This means that all textual stuff coming out of the repository is converted to CRLF, and all textual stuff going into it is converted to LF.
This, however, proves a problem in case any CRLF line is in the repository, because in this case a clean checkout will seem modified to git, blocking almost all functionality (many things aren't allowed in unclean working tree).
I found that the following setting, contrary to the msysgit default, works best for me:
git config -f .git/config core.autocrlf input
This way this setting only applies to the current repository, and not to all your other git repositories. It's effect is that you get all files checked out as they are in the repository, ie. usually with LF line endings. Because any decent tool does not choke on different line endings, this usually isn't a problem, and because git converts stuff to LF on commit, you don't risk messing up the repository either (by putting more CRLF line endings in it.)
Compiling the project¶
- Launch Visual Studio.
- Open the SpringLobby solution (.sln) file.
- Choose the desired configuration (Debug or Release).
- Press F7 to compile.
- Wait patiently until the compile finished. (Grab coffee.)
- Copy the DLLs from "C:\Sourcecode\Libraries\wxWidgets2.8\lib\vc_dll" to the output directory. ("bin/Debug", "bin/Release", whatever you picked earlier.)
- Copy SDL DLLs from where you installed SDL to the output directory.
- Press F5 to run.
Next time you can just use F5 / F7 to compile/run, you only need to do all the other steps once of course.
Troubleshooting¶
Manifest¶
When trying to build a debug build of SpringLobby in Visual Studio you might get the following errors during the linker step:
CVTRES : fatal error CVT1100: duplicate resource. type:MANIFEST, name:1, language:0x0409 LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
To fix this, turn off manifest embedding in the project properties -> manifest tool -> Input and Output -> embed manifest, for both springlobby and springsettings.
NOTE: OBSOLETE
With the above setup you may get the following linker errors:
springunitsynclib.obj : error LNK2001: unresolved external symbol "protected: virtual void +thiscall wxLogGui::DoLog(unsigned long,char const *,+int64)" springunitsynclib.obj : error LNK2001: unresolved external symbol "protected: virtual void +thiscall wxLog::DoLogString(char const *,+int64)" replaylist.obj : error LNK2001: unresolved external symbol "+declspec(dllimport) public: class wxDateTime & +thiscall wxDateTime::Set(+int64)"
It is as of yet unknown what causes these, so I recommend to comment out the offending lines, like this:
-------------------------- src/replay/replaylist.cpp --------------------------
index a572733..c6454da 100644
@@ -268,7 +268,7 @@ void [[ReplayList]]::GetHeaderInfo( Replay& rep, const wxString& [[ReplayPath]] )
replay.Seek( 56 );
replay.Read( &unixtime, 8 );
wxDateTime dt;
- dt.Set( (time_t) unixtime );
+ //dt.Set( (time_t) unixtime );
/// todo: add 2 strings one for date other for time?
wxString date = dt.FormatISODate()+_T(" ")+dt.FormatISOTime();
rep.date = date;
-------------------------- src/springunitsynclib.cpp --------------------------
index 548b20d..18d15c4 100644
@@ -80,9 +80,9 @@ void [[SpringUnitSyncLib]]::_Load( const wxString& path )
}
{
- wxLog *currentarget = wxLog::GetActiveTarget();
- wxLog *templogger = new wxLogGui();
- wxLog::SetActiveTarget( templogger );
+ //wxLog *currentarget = wxLog::GetActiveTarget();
+ //wxLog *templogger = new wxLogGui();
+ //wxLog::SetActiveTarget( templogger );
try {
#ifdef +WXMSW+
wxSetWorkingDirectory( path.BeforeLast('\\') );
@@ -95,8 +95,8 @@ void [[SpringUnitSyncLib]]::_Load( const wxString& path )
} catch(...) {
m_libhandle = 0;
}
- wxLog::SetActiveTarget( currentarget );
- delete templogger;
+ //wxLog::SetActiveTarget( currentarget );
+ //delete templogger;
}
ASSERT_EXCEPTION( m_libhandle != 0, _T("Couldn't load the unitsync library") );
If you get other linker errors about symbols not being found, it may be that the Visual Studio project file isn't entirely up to date. Try to determine in which file the symbols are defined, add this to the project and try the build again.
If you encounter troubles with any of the steps, please check the guide again and if doesn't help, contact the lobby developers.