Archive/Compiling

First of all you should consider that Glest's developed has stopped in april 2009. There are two projects which continue and have added lots of features, factions and maps since then. ... but based on this where you are you maybe want to compile MegaGlest instead, then just follow this link: MegaGlest Development

Glest's source is divided into 2 parts:
 * 1) Game source: Glest game specific code.
 * 2) Shared library source: Code that is shared among all Glest tools and other projects Glest has.

We have to compile the shared library as static library and the link the main code against it. Both of them use a single thread so you don't need multi-thread support.

This shared library is also divided into several sub-modules:
 * graphics: math and graphics
 * graphics_gl: opengl graphics
 * sound: sound (including the direct sound player)
 * util: conversion functions and other utilities
 * platform: platform dependent code (to make a port of Glest to other platforms only this part needs to be changed)

Requirements

 * A compiler
 * Glest's Source
 * Header files

Libraries
The name is most likely [libraryname]-devel especially in package management software.
 * SDL
 * OpenAL SDK
 * Xerces-c
 * OggVorbis
 * OpenGL SDK
 * Mesa3D or XFree86 for GLU headers and libraries

Programs
If not using Microsoft Visual Studio
 * Jam (not Boost Jam)
 * Possibly Autoconf which needs GNU m4 and perl
 * Possibly Autogen

Prerequisites

 * Download and install Microsoft Visual C++ 2008 Express Edition (MSVC++). MSDN documentation is optional, but helpful. Decide where you want to check out glest and put your dependencies.  This location will be referred to as [root] from this point on.
 * Download and extract the all-in-one win32-glest-deps.rar into [root]. Checkout the glest sources. This should look something like this:

svn co https://glest.svn.sourceforge.net/svnroot/glest/trunk glest

Creating the "Solution" and "Projects"
MSVC++ projects are contained in a "solution" (analogous to a "workspace" in other IDEs). A single solution can contain multiple projects. We want to create a single solution in the [root]\glest\source directory that contains projects for each of the shared_lib, glest_game and optionally g3d_viewer and map_editor directories.

Create an empty solution named "Glest"

 * Create a new solution with a dummy project: Click File > New > Project From Existing Code. Visual C++ project should be selected.
 * Set the project file location to [root]\glest\source and the project name to Glest.
 * Remove the Glest project from the solution.
 * Close & save the solution (File > Close Solution</tt>).
 * Browse to [root]\glest\source and delete all of the files that were just created except for Glest.sln</tt>

Now we have our blank solution that we'll add subprojects to later.

Create projects

 * To create the individual projects, File > New project from existing code</tt> and set the Project file location to [root]\glest\sourced\shared_lib</tt> and the project name to libglest</tt>.
 * Set the project type as a Static library (LIB) project</tt>.
 * Repeat this for [root]\glest\sourced\glest_game</tt> with the project name game</tt>.
 * This can optionally be repeated for g3d_viewer</tt> and map_editor</tt>.
 * Close the open solution (File > Close Solution</tt>).
 * Using windows explorer, go to each of the subproject folders and delete the .ncb</tt>, .sln</tt> and .suo</tt> files. These are for the solution tied each of these projects that we don't need.

Put it all together
Open the original "Glest" solution and add each project (File > Add > Existing Project</tt>).

Configure project properties

 * Go to Project > Project Dependencies</tt> and set all projects besides <tt>libglest</tt> as being dependent on <tt>libglest</tt>.
 * Select all projects and go to properties page.
 * From the Configuration drop down at the top of the window, select All Configurations. We will now be editing the properties for all projects and all configurations, so be careful what you change.
 * Set <tt>C/C++ > General > Additional Include Directories</tt> using the below values. Just delimit them with a semicolon and copy and paste.

..\..\..\deps\include ..\shared_lib\include\sound\ds8 ..\shared_lib\include\graphics ..\shared_lib\include\graphics\gl ..\shared_lib\include\platform\win32 ..\shared_lib\include\sound ..\shared_lib\include\util ..\shared_lib\include\xml


 * Set <tt>C/C++ > General > Warning Level</tt> to 2 to avoid excess spam.
 * If you want to debug using the edit and continue debug database, click Apply, switch to the debug configuration and set <tt>C/C++ > Code Generation > Enable Function-Level Linking</tt> to yes.
 * Select only the game project and go into it's properties.
 * Add all of the directories in the game project to it's own include path (<tt>C/C++ > General > Additional Include Directories</tt>).
 * Now select only the exe projects (<tt>game</tt>, <tt>g3d_viewer</tt> and <tt>map_editor</tt>) and go into those project properties.
 * Again, select all configurations
 * Set <tt>Linker > General > Additional Library Directories</tt> to include

..\..\..\deps\lib ..\shared_lib\$(ConfigurationName)


 * Set <tt>Linker > Input > Additional Dependencies</tt> to the below value. (Note: This presumes that you want to statically link as much as possible. Otherwise, you can choose to use dyanamic <tt>.lib</tt> files, but the DLLs will be required at run time.)

dsound.lib dxguid.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib xerces-c_2.lib opengl32.lib glu32.lib wsock32.lib libglest.lib mmc.lib

Removing unused sources & adding glprocs
Not all subdirectories of this project should be compiled on windows. Additionally, the D3D implementation is incomplete. So select the following subdirectories of <tt>shared_lib</tt>, right click and select <tt>Exclude From Project</tt>.

sources/graphics/d3d9 sources/graphics/gl2 sources/platform/sdk sources/platform/posix sources/sound/openal

Right click on the <tt>libglest</tt> project, select <tt>Add/Existing Item</tt> and browse to <tt>deps/src/glprocs.c</tt>

Troubleshooting
If you compile Glest and somebody else tries to run in on their machine and they get "Application failed to start because side-by-side configuration is incorrect" then they either need to install Microsoft Visual C++ 2008 Redistributable Package (x86) or you need to link in the C runtime libraries statically. The later basically involves setting <tt>C/C++ > Code Generation > Runtime Libray</tt> to "Multi-threaded (/MT)" and then adding <tt>libcmt.lib</tt> in <tt>Linker > Input > Additional Dependencies</tt> and will generate a slightly larger file.