Difference between revisions of "Archive/Compiling"

From MegaGlest
Jump to navigation Jump to search
(Fixing apparently broken link re using Visual Studio)
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Overview==
+
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: [https://docs.megaglest.org/MG/Development MegaGlest Development]
Glest source is divided into 2 parts:<br>
 
a) Game source: Glest game specific code.<br>
 
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.
+
 
 +
[[Glest|Glest's]] source is divided into 2 parts:
 +
#Game source: Glest game specific code.
 +
#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:
 
This shared library is also divided into several sub-modules:
Line 15: Line 17:
 
==Requirements==
 
==Requirements==
 
*A compiler
 
*A compiler
*Glest Source
+
*Glest's Source
 
*Header files
 
*Header files
  
Line 27: Line 29:
 
*[http://www.mesa3d.org/ Mesa3D] or [http://www.xfree86.org/ XFree86] for GLU headers and libraries
 
*[http://www.mesa3d.org/ Mesa3D] or [http://www.xfree86.org/ XFree86] for GLU headers and libraries
  
===Programs (non-MSVS)===
+
===Programs===
* [http://www.perforce.com/jam/jam.html Jam] (not Boost Jam)
+
<small>If not using Microsoft Visual Studio</small>
* It might need [http://www.gnu.org/software/autoconf/ Autoconf] which needs GNU m4 and perl
+
*[http://www.perforce.com/jam/jam.html Jam] (not Boost Jam)
* Possibly [http://www.gnu.org/software/autogen/ Autogen]
+
*Possibly [http://www.gnu.org/software/autoconf/ Autoconf] which needs GNU m4 and perl
 
+
*Possibly [http://www.gnu.org/software/autogen/ Autogen]
==Linux compile hints==
 
http://hailstone3.truefreehost.com/?p=5
 
==Using MS Visual Studio .Net 2003==
 
'''deprecated'''
 
'''[http://glest.org/glest_board/index.php?topic=3271.0 Use this]'''
 
<pre>
 
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
+
==Compiling with Microsoft Visual Studio 2008==
C:\Development\Glest\oggvorbis-win32sdk-1.0.1\oggvorbis-win32sdk-1.0.1\lib
+
===Prerequisites===
C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60\xerces-c_2_6_0-windows_nt-msvc_60\bin
+
*Download and install [http://http//www.microsoft.com/express/download 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 <tt>[root]</tt> from this point on.
C:\Development\Glest\xerces-c_2_6_0-windows_nt-msvc_60\xerces-c_2_6_0-windows_nt-msvc_60\lib
+
*Download and extract the all-in-one win32-glest-deps.rar into [root]. Checkout the glest sources.  This should look something like this:
  
NOTE: Make sure when you are adding the include folders, you actually navigate to the folders to ensure they exist
+
svn co https://glest.svn.sourceforge.net/svnroot/glest/trunk glest
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
+
===Creating the "Solution" and "Projects"===
Everything should be ready to go. Simply right click the GlestLib project and select Build. It takes about 1
+
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 <tt>shared_lib</tt>, <tt>glest_game</tt> and optionally <tt>g3d_viewer</tt> and <tt>map_editor</tt> directories.
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
+
===Create an empty solution named "Glest"===
What we need to do now, is to create a project in Visual Studio that will contain the files for the Glest source
+
*Create a new solution with a dummy project: <tt>Click File > New > Project From Existing Code</tt>. Visual C++ project should be selected.
that we will be building. We will then set the appropriate include paths/folders and library search paths, and  
+
*Set the project file location to <tt>[root]\glest\source</tt> and the project name to <tt>Glest</tt>.
finally compile the source. So, first thing is to create a Visual Studio project. To do that, Open Visual Studio.
+
*Remove the Glest project from the solution.
 +
*Close & save the solution (<tt>File > Close Solution</tt>).
 +
*Browse to [root]\glest\source and delete all of the files that were just created except for <tt>Glest.sln</tt>
  
Select File, New Project. Under 'Visual C++ Projects', select the project type of 'Win32 Project'. Enter the name
+
Now we have our blank solution that we'll add subprojects to later.
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
+
===Create projects===
Existing Item'. Navigate to the C:\Development\Glest\Glest_source_v1.0.10\glest_source_v1.0.10\sources folder.  
+
*To create the individual projects, <tt>File > New project from existing code</tt> and set the Project file location to <tt>[root]\glest\sourced\shared_lib</tt> and the project name to <tt>libglest</tt>.
Notice how all the *.cpp and *.h files are listed together? In the Filename box at the bottom, type in *.cpp and  
+
*Set the project type as a <tt>Static library (LIB) project</tt>.
press enter. This will now only display the *.cpp files. Select them all and then click the Open button. These  
+
*Repeat this for <tt>[root]\glest\sourced\glest_game</tt> with the project name <tt>game</tt>.  
files should now appear in the 'Sources' folder of your project. Add the header files in the same way, except type
+
*This can optionally be repeated for <tt>g3d_viewer</tt> and <tt>map_editor</tt>.
in *.h instead of *.cpp to filter out all but the header files.
+
*Close the open solution (<tt>File > Close Solution</tt>).
 +
*Using windows explorer, go to each of the subproject folders and delete the <tt>.ncb</tt>, <tt>.sln</tt> and <tt>.suo</tt> files. These are for the solution tied each of these projects that we don't need.
  
Ok - before we can compile, we need to tweak the project settings a little bit, so right click your project
+
===Put it all together===
'GlestSrc' in visual studio, and select Properties. Expand the C/C++ folder and select General. Click the
+
Open the original "Glest" solution and add each project (<tt>File > Add > Existing Project</tt>).
'Additional Include Directories' and set this as follows:
 
  
C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\xml
+
===Configure project properties===
C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\util
+
*Go to <tt>Project > Project Dependencies</tt> and set all projects besides <tt>libglest</tt> as being dependent on <tt>libglest</tt>.
C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\sound
+
*Select all projects and go to properties page.
C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\platform
+
*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.
C:\Development\Glest\shared_lib_source_v0.2\shared_lib_source_v0.2\include\graphics\gl
+
*Set <tt>C/C++ > General > Additional Include Directories</tt> using the below values. Just delimit them with a semicolon and copy and paste.
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
+
..\..\..\deps\include
the Library folders by right clicking your project 'GlestSrc' in visual studio, and select Properties. Expand the
+
..\shared_lib\include\sound\ds8
Linker folder and select General. Click the 'Additional Library Directories' and set this as follows:
+
..\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
  
C:\Development\Glest\GlestLib\GlestLib\Debug
+
*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
  
On the Input folder (under Linker), set the 'Additional Dependencies' as follows:
+
..\..\..\deps\lib
 +
..\shared_lib\$(ConfigurationName)
  
C:\Development\Glest\GlestLib\GlestLib\Debug\GlestLib.lib
+
*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.)
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.
+
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
  
Step 8 - Build Glest Source
+
===Removing unused sources & adding glprocs===
Ok - everything should be in place. Right click your GlestSrc project and click Build, or if you have already
+
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>.
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
+
sources/graphics/d3d9
Glest folder that you created in step 1 above and run *YOUR* compiled exe.
+
sources/graphics/gl2
 +
sources/platform/sdk
 +
sources/platform/posix
 +
sources/sound/openal
  
Step 9 - Running the newly compiled exe
+
Right click on the <tt>libglest</tt> project, select <tt>Add/Existing Item</tt> and browse to <tt>deps/src/glprocs.c</tt>
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
+
===Troubleshooting===
</pre>
+
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.
  
==Using Dev-C++==
+
==See also==
 +
*[[GAE]]
 +
*[[MegaGlest]]
 +
[[Category:Glest]]
 +
[[Category:Source]]

Revision as of 14:37, 13 February 2016

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.

Programs

If not using Microsoft Visual Studio

Compiling with Microsoft Visual Studio 2008

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).
  • Browse to [root]\glest\source and delete all of the files that were just created except for Glest.sln

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 and set the Project file location to [root]\glest\sourced\shared_lib and the project name to libglest.
  • Set the project type as a Static library (LIB) project.
  • Repeat this for [root]\glest\sourced\glest_game with the project name game.
  • This can optionally be repeated for g3d_viewer and map_editor.
  • Close the open solution (File > Close Solution).
  • Using windows explorer, go to each of the subproject folders and delete the .ncb, .sln and .suo 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).

Configure project properties

  • Go to Project > Project Dependencies and set all projects besides libglest as being dependent on libglest.
  • 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 C/C++ > General > Additional Include Directories 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 C/C++ > General > Warning Level 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 C/C++ > Code Generation > Enable Function-Level Linking 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 (C/C++ > General > Additional Include Directories).
  • Now select only the exe projects (game, g3d_viewer and map_editor) and go into those project properties.
  • Again, select all configurations
  • Set Linker > General > Additional Library Directories to include
..\..\..\deps\lib
..\shared_lib\$(ConfigurationName)
  • Set Linker > Input > Additional Dependencies to the below value. (Note: This presumes that you want to statically link as much as possible. Otherwise, you can choose to use dyanamic .lib 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 shared_lib, right click and select Exclude From Project.

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

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

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 C/C++ > Code Generation > Runtime Libray to "Multi-threaded (/MT)" and then adding libcmt.lib in Linker > Input > Additional Dependencies and will generate a slightly larger file.

See also