Archive/Compiling

Overview
Glest source is divided into 2 parts: a) Game source: Glest game specific code. b) Shared library source: Code that is shared among all Glest tools and other projects we have.

What we do is 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 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 (non-MSVS)

 * Jam (not Boost Jam)
 * It might need Autoconf which needs GNU m4 and perl
 * Possibly Autogen

Linux compile hints
http://hailstone3.truefreehost.com/?p=5

Using MS Visual Studio .Net 2003
deprecated Use this Posted: Mon Feb 21, 2005 Author: David Lendrum Email: devoidREMOVEME@REMOVEMEbigpond.net.au

This guide was written on February 21st, 2005. File locations/versions may have changed since this was written. I will attempt to keep the information here as current as possible.

If you have any questions, or find any errors with the instructions, email me and I will fix them up. I will also post a list of 'common problems' and solutions (assuming people have problems) in the near future based on information people have sent me.

NOTE: This is not how I would set up the development project with regard to locations and directory structure, but it was the simplest to get working. Feel free once you have got everything working to play around and re-organise stuff.

Requirements: This guide was written for the following environment: - Windows XP Professional SP2 - Microsoft Visual Studio.Net 2003 Enterprise Edition - WinZip (or other unpacking tool)

Step 1 - Make sure your machine can run Glest! Ok - Before trying to compile anything, make sure your machine can actually run Glest. This should not be a problem for most Windows based machines around today. You will need to download the Glest binaries from SourceForge and install them. These files are available in the Glest project area, at this link:

https://sourceforge.net/project/showfiles.php?group_id=127297

You want to download the 'glest win32' package (currently 1.0.9 and is about 39MB in size). Once you have it downloaded, unpack and install it. This is the complete game with binaries, graphics and sound resources. Once the game has been installed, run it to make sure it works ok. Notice on the startup screen the version number is v1.0.9. Don't skip this step! Once we compile our own .EXE we will copy it into this folder and run it, so you need all of the Glest resources in their correct places in order for it to work.

Step 2 - Unpacking the Glest Source Ok, that was the easy bit. Smile The Glest source files are located at the same location on SourceForge (see link above). You need to download and save the 'glest shared library source' (currently v0.2 which is about 125k in size) and also the 'glest source' (currently v1.0.10 and 184k in size). These 2 packages contain the source files we will be compiling. I created a folder in my C: drive and called it 'Development' and then created another folder inside the Development one called 'Glest' (C:\Development\Glest). The instructions that follow assume the same folder structure, so change them to suit your machine.

Unpack the 'shared_lib_source_v0.2.zip' file into the C:\Development\Glest folder. I just used the Windows XP Extract Compressed Folders program (right click the .zip file, select 'Extract All' hit Next, then Next again, untick the 'Show Extract Files' box, then click Finish), but WinZip or any other program for unpacking ZIP files will work fine. This should automatically create a sub folder of the same name as the .zip archive.

NOTE: On my machine the folder names are doubled up as you will see shortly. Be aware of this if you are using another program like WinZip that doesn't do it this way.

Also, unpack the 'glest_source_v1.0.10.zip' file into the C:\Development\Glest folder. You should now have the following folder structure:

C:\Development\Glest C:\Development\Glest\glest_source_v1.0.10 C:\Development\Glest\shared_lib_source_v0.2

Step 3 - Getting the Other Libraries Before you can compile the Glest Shared Library, you need to download the following archives into your C:\Development\Glest folder:

Xerces 2.6.0 [The file doesn't exist at that address anymore] Filename: xerces-c_2_6_0-windows_nt-msvc_60.zip Location: http://www.apache.org/dist/xml/xerces-c/binaries/WinNT_msvc60/xerces-c_2_6_0-windows_nt-msvc_60.zip

OggVorbis Win32 SDK 1.0.1 Filename: OggVorbis-win32sdk-1.0.1.zip Location: http://www.vorbis.com/files/1.0.1/windows/OggVorbis-win32sdk-1.0.1.zip

OpenGL SDK files Filename: glsdk.zip Location: http://oss.sgi.com/projects/ogl-sample/GLsdk.zip

Unpack the above three archives into the C:\Development\Glest folder. You should now have the following folder structure under C:\Development:

C:\Development\Glest C:\Development\Glest\glest_source_v1.0.10 C:\Development\Glest\GLsdk C:\Development\Glest\shared_lib_source_v0.2 C:\Development\Glest\oggvorbis-win32sdk-1.0.1 C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60

Step 4 - Creating a Visual Studio Project for the Shared Library What we need to do now, is to create a project in Visual Studio that will contain the files for the Shared Library that we will be building. We will then set the appropriate include paths/folders and library search paths, and finally compile the shared library. So, first thing is to create a Visual Studio project. To do that, Open Visual Studio. Select File, New Project. Under 'Visual C++ Projects', select the project type of 'Win32 Project'. Enter the name of the project as 'GlestLib'. Change the location of the project to C:\Development\Glest. Create a new folder and call it 'GlestLib' (make sure this folder is selected in the Project Location dialog), then click Open. On the New Project dialog window, click Ok. This will start the Win32 Application Wizard. Select 'Application Settings' under 'Overview' and make sure the Application Type is set to 'Static Library'. Leave all other options as their default. Click Finish.

Now, we need to create some folders in our project to help keep the files organised. So, back in Visual Studio (you should still have your GlestLib project open, if not, open it), right click the 'Source Files' folder and click 'New Folder'. Call this folder 'Graphics'. Create more folders in the 'Source Files' and call them 'Platform', 'Sound','Util' and 'Xml'. Also, you need to create another folder INSIDE the Graphics folder and call it 'GL'. Now we can add the source files to the relevant folder, so, right click the folder called 'Graphics' and select 'Add Existing Item'. On the Add Existing Item dialog box, navigate to the C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\Sources\Graphics folder. Notice the GL folder? We will use that in a minute. Select all of the *.cpp files and then click the Open button. These will now be added to your project. Now right click the 'GL' folder under 'Graphics' in your project and select 'Add Existing Item'. Navigate to the same location as above but go one folder deeper into the \Graphics\GL folder and select all of the *.cpp files and click Open. These should be added to the subfolder called 'GL' under your 'Graphics' folder in your Visual Studio project. Now, repeat the step above for the 'Platform', 'Sound', 'Util' and 'XML' folders.

We now need to do the same thing for the Header files. So create the same folder structure under the Header Files in your project ('Graphics', 'Graphics\GL', 'Platform', 'Sound', 'XML'). After creating the folder, repeat the above steps for adding the files, but navigate to the C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\Include folder. This time we will be adding all of the files with a *.h extension instead of *.cpp.

We also need to a few of the Open GL files to the project. There is one source file (glprocs.c) and some header files (wglext.h, gl.h, glext.h, glprocs.h). These files are located in the C:\Development\Glest\GLsdk\GLsdk\GL folder. Use the method described above to add the one source file and the 4 headers files. Just put them into the 'Source Files' and 'Header Files' folders respectively.

Step 5 - Set Visual Studio Project Settings Ok - before we can compile, we need to tweak the project settings a little bit, so right click your project 'GlestLib' in visual studio, and select Properties. Expand the C/C++ folder and select General. Click the 'Additional Include Directories' and set this as follows:

C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\xml C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\util C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\sound C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\platform C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\graphics\gl C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\graphics C:\Development\Glest\GLsdk\GLSdk\GL C:\Development\Glest\oggvorbis-win32sdk-1.0.1\oggvorbis-win32sdk-1.0.1\include C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60\xerces-c_2_6_0-windows_nt-msvc_60\include

Under the General folder, set the 'Create/Use Precompiled Header' to 'Not using precompiled headers'.

Under the Librarian folder, in the 'Additional Library Directories', set this as follows:

C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib C:\Development\Glest\oggvorbis-win32sdk-1.0.1\oggvorbis-win32sdk-1.0.1\lib C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60\xerces-c_2_6_0-windows_nt-msvc_60\bin C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60\xerces-c_2_6_0-windows_nt-msvc_60\lib

NOTE: Make sure when you are adding the include folders, you actually navigate to the folders to ensure they exist at the same location on your machine. If you simply cut/paste the location of the folders from above, you may find they are in a slightly different location and the compile will fail.

Step 6 - Build the Shared Library Everything should be ready to go. Simply right click the GlestLib project and select Build. It takes about 1 minute 30 seconds on my machine and it builds with no errors, but 54 warnings (which can be ignored). After the build, check the output folder of your project which should be something like C:\Development\Glest\GlestLib\GlestLib\Debug and look for the GlestLib.lib file. Mine is 7,617kb. This is the file that we need to link into the Glest Source when we compile that, which moves us onto...

Step 7 - Creating a Visual Studio Project for the Glest Source What we need to do now, is to create a project in Visual Studio that will contain the files for the Glest source that we will be building. We will then set the appropriate include paths/folders and library search paths, and finally compile the source. So, first thing is to create a Visual Studio project. To do that, Open Visual Studio.

Select File, New Project. Under 'Visual C++ Projects', select the project type of 'Win32 Project'. Enter the name of the project as 'GlestSrc'. Change the location of the project to C:\Development\Glest. Create a new folder and call it 'GlestSrc' (make sure this folder is selected in the Project Location dialog), then click Open. On the New Project dialog window, click Ok. This will start the Win32 Application Wizard. Select 'Application Settings' under 'Overview' and make sure the Application Type is set to 'Windows Application' and tick the box for 'Empty Project'. Leave all other options as their default. Click Finish.

Now we need to add some modules to our project. To do this, right click the 'Source Files' folder and click 'Add Existing Item'. Navigate to the C:\Development\Glest\Glest_source_v1.0.10\glest_source_v1.0.10\sources folder. Notice how all the *.cpp and *.h files are listed together? In the Filename box at the bottom, type in *.cpp and press enter. This will now only display the *.cpp files. Select them all and then click the Open button. These files should now appear in the 'Sources' folder of your project. Add the header files in the same way, except type in *.h instead of *.cpp to filter out all but the header files.

Ok - before we can compile, we need to tweak the project settings a little bit, so right click your project 'GlestSrc' in visual studio, and select Properties. Expand the C/C++ folder and select General. Click the 'Additional Include Directories' and set this as follows:

C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\xml C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\util C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\sound C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\platform C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\graphics\gl C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\graphics C:\Development\Glest\GLsdk\GLSdk\GL C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60\xerces-c_2_6_0-windows_nt-msvc_60\include C:\Development\Glest\oggvorbis-win32sdk-1.0.1\oggvorbis-win32sdk-1.0.1\include

Before we can compile, we also need to set the Library folder, so the project can link in the necessary files. Set the Library folders by right clicking your project 'GlestSrc' in visual studio, and select Properties. Expand the Linker folder and select General. Click the 'Additional Library Directories' and set this as follows:

C:\Development\Glest\GlestLib\GlestLib\Debug

On the Input folder (under Linker), set the 'Additional Dependencies' as follows:

C:\Development\Glest\GlestLib\GlestLib\Debug\GlestLib.lib C:\Development\Glest\oggvorbis-win32sdk-1.0.1\oggvorbis-win32sdk-1.0.1\lib\ogg_static.lib C:\Development\Glest\oggvorbis-win32sdk-1.0.1\oggvorbis-win32sdk-1.0.1\lib\vorbis_static.lib C:\Development\Glest\oggvorbis-win32sdk-1.0.1\oggvorbis-win32sdk-1.0.1\lib\vorbisfile_static.lib C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60\xerces-c_2_6_0-windows_nt-msvc_60\lib\xerces-depdom_2.lib C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60\xerces-c_2_6_0-windows_nt-msvc_60\lib\xerces-c_2.lib "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib\OpenGL32.lib" "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib\glu32.lib" "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib\glaux.lib" "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib\dsound.lib" "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib\dxguid.lib"

Note: The " around the folder locations above are required for any paths that contain spaces in them.

Step 8 - Build Glest Source Ok - everything should be in place. Right click your GlestSrc project and click Build, or if you have already tried to build it and it has failed, click Clean Solution, then click Build. On my machine a it takes a few minutes to compile and compiles with 0 errors and 933 warnings (ignore the warnings).

If you have got to this point - congratulations! All you have to do now is copy your .EXE (and a .DLL file) to the Glest folder that you created in step 1 above and run *YOUR* compiled exe.

Step 9 - Running the newly compiled exe Ok - this is the easy step. Navigate to the Glest folder where you installed the original game in step 1. I used the standard defaults so on my machine it is installed into C:\Program Files\Glest_v1.0.9. Open Windows Explorer and navigate to that folder. Rename 'glest.exe' to 'glest.ORIGINAL.exe' and rename 'xerces-c_2_3_0.dll' to 'xerces-c_2_3_0.ORIGINAL.dll'. Now copy the compiled 'Glest.exe' from C:\Development\Glest\GlestSrc\Glest\Debug to the folder where you installed Glest. Also, copy in the file 'C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60\xerces-c_2_6_0-windows_nt-msvc_60\bin\xerces-c_2_6.dll' to the folder where you installed Glest. Run the 'Glest.exe' and you should notice the version is now 1.0.10 (not 1.0.9) - play the game and see that it works ok.

Thats it! Simple really... Wink