Difference between revisions of "MG/Windows Compiling"

From MegaGlest
Jump to navigation Jump to search
(Rearranged, separated CLI vs GUI build approach, updated for VC++ 2010)
Line 1: Line 1:
 
This page explains how to compile [[MegaGlest]] for Windows.
 
This page explains how to compile [[MegaGlest]] for Windows.
  
==Compiling from source==
+
==Two approaches==
#Install [http://www.microsoft.com/express/downloads/#2008-Visual-CPP Visual Studio]. It is recommended that [http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express Visual C++ 2008] '''WITH''' '''Service Pack 1''' ([http://download.microsoft.com/download/A/5/4/A54BADB6-9C3F-478D-8657-93B3FC9FE62D/vcsetup.exe direct download of VC++ 2008 Express Edition]) be used. VC++ 2010 project files are also included and ''may'' work but are not the primary environment used by MegaGlest developers, i.e. they may not be up to date and you may need to tweak them to make them work for you.
+
Generally, there are two approaches to get your work done:
#[[MG/Getting The Code|Get the project ]] from [[MG/SVN Structure|MegaGlest's subversion repository]] using the command line ([http://www.sliksvn.com/en/download Slik SVN] is recommended because the batchfile compile function is dependant on this program) or your favorite subversion utility. If you are going to use subversion on 64-bit Windows 7 and get error messages like ''The file or directory is corrupted and unreadable'' then that's because your OS's only primary file system [http://glest.org/glest_board/?topic=5611.msg58480#msg58480 is buggy].
+
*CLI: the automatable and fast one, using command line utilities and batch files
#Download the [https://sourceforge.net/projects/megaglest/files/win32_deps.7z/download build dependencies archive].
+
*GUI: the slow and shiny one, using graphical user interfaces
#Decompress (using [http://www.7-zip.org/ 7-zip]) the dependency archive into the folder named <tt>source</tt>. You should now see a <tt>win32_deps</tt> sub-folder with many files inside.
 
#Open the main solution in [http://www.microsoft.com/express/downloads/#2008-Visual-CPP Visual Studio], located in <tt>mk/windoze/Glest.sln</tt>
 
#Perform a rebuild project.
 
#If nothing goes wrong you will see <tt>megaglest.exe</tt> (and other binaries) in <tt>data/glest_game</tt> (where all the data content lives).
 
#To test the game, run the batch file <tt>CopyWindowsRuntimeDlls.bat</tt> located in <tt>mk\windoze</tt> to copy dependency dll's to the runtime binary folder.
 
  
==Windows Compiling in a Batch==
+
The MegaGlest developers prefer the first approach, and this is also the most tested and recommended approach. You can also choose the GUI approach, which ''should'' work, but please do not expect us to support you with setting up your VC++ build environment or GUI SVN client since this is hard to support and eats a lot of time. So if you choose this approach, please do not ask for support unless you do know how this is done properly and that the issues you are running into are clearly due to a bug in the solution files or this documentation.
[[File:SS_of_MG_Windows_Batch_File.png|thumb|MegaGlest batch file.]]
 
There is a convenient batch file (which assumes you have installed [http://www.sliksvn.com/en/download SlikSVN] for subversion command line use) which will:
 
  
#Update the branch you are working in with the latest subversion code
+
==Prepare==
#Touch the game_util.cpp file with the latest date/time
+
*Install [http://www.microsoft.com/visualstudio/eng/products/visual-studio-2010-express Visual C++ Express 2010] as well as any service packs available for it (if any).
#Compile all projects from command line
+
*Install [http://www.7-zip.org/ 7-Zip] or a compatible file archiving utility.
  
This batch file exists within with <tt>mk\windoze</tt> folder and is called: <tt>build-mg.bat</tt>
+
==The CLI approach==
 +
*Install [http://www.sliksvn.com/en/download Slik SVN] and use it to [[MG/Getting The Code|check out the MegaGlest source code and game data]] into your local [[MG/SVN Structure|Subversion working copy]].
 +
*Ensure that the <tt>7-zip</tt> command is available globally (add it to your PATH). At the time of writing, the 7-Zip installer will take care of this for you.
 +
*Locate and run the [[File:SS_of_MG_Windows_Batch_File.png|thumb|MegaGlest batch file]] <tt>mk\windoze\build-mg-2010.bat</tt> which automates the following steps for you:<br>
 +
- Download and extract the [http://sourceforge.net/projects/megaglest/files/windows_deps.7z build dependencies archive] unless you already have it<br>
 +
- Update the branch you are working in with the latest subversion code<br>
 +
- Update the timestamp and revision no. on the<br><tt>source\glest_game\facilities\game_util.cpp</tt> file<br>
 +
- Compile all projects from command line
 +
*If nothing goes wrong you will see <tt>megaglest.exe</tt> (and other binaries) in <tt>data\glest_game\</tt> (where all the data content lives).
 +
*On the first run, also run the <tt>mk\windoze\CopyWindowsRuntimeDlls_2010.bat</tt> batch file to copy runtime dependency DLL's to the runtime binary folder.
  
If you need to do a full rebuild you can pass this parameter to the bat file command line "n rebuild"
+
==The GUI approach==
 +
*Read the above ''Two approaches'' paragraph since it provides important information on the limits of this aproach.
 +
*Install [http://tortoisesvn.net/downloads.html TortoiseSVN] or a similar Subversion client and use it to [[MG/Getting The Code|check out the MegaGlest source code and game data]] into your local [[MG/SVN Structure|Subversion working copy]].
 +
*Download the [http://sourceforge.net/projects/megaglest/files/windows_deps.7z build dependencies archive].
 +
*Decompress the 7-zip compressed build dependencies archive into the <tt>source</tt> subdirectory of your Subversion working copy. You should then see a <tt>source\windows_deps\</tt> directory with many files inside.
 +
*Start Visual C++ 2010 and open the main solution, located in <tt>mk\windoze\Glest_vc2010.sln</tt>
 +
*Perform a rebuild project.
 +
*If nothing goes wrong you will see <tt>megaglest.exe</tt> (and other binaries) in <tt>data\glest_game\</tt> (where all the data content lives).
 +
*On the first run, also run the <tt>mk\windoze\CopyWindowsRuntimeDlls_2010.bat</tt> batch file to copy runtime dependency DLL's to the runtime binary folder.
  
==Usefull Infomation==
+
==Trouble shooting==
  
The Megaglest Trunk SVN is:https://megaglest.svn.sourceforge.net/svnroot/megaglest/trunk
+
===Subversion===
 +
If you are using subversion on 64-bit Windows 7 and get error messages like ''The file or directory is corrupted and unreadable'' then that's probably because of [http://glest.org/glest_board/?topic=5611.msg58480#msg58480 a bug in NTFS].
  
 +
===Building===
 +
If your build fails, this can be due to an outdated build dependencies. Check http://sourceforge.net/projects/megaglest/files/ for when the <tt>windows_deps.7z</tt> file was last updated, and if it's more recent than the one you extracted the files in <tt>source\windows_deps\</tt> from (or if you do not know), then recursively delete both <tt>source\windows_deps\</tt> and <tt>source\windows_deps.7z</tt>.
 +
 +
When using the GUI approach, you also need to manually download the updated [http://sourceforge.net/projects/megaglest/files/windows_deps.7z build dependencies archive] and extract it into the <tt>source\</tt> directory in your subversion working copy. With the CLI approach, this will be done automatically on next build.
 +
 +
===Running===
 +
If MegaGlest crashes you should '''do a full rebuild'''. To do so with the CLI approach, instead of just running <tt>mk\windoze\build-mg-2010.bat</tt>, run <tt>mk\windoze\build-mg-2010.bat n rebuild</tt> to trigger a full rebuild.
 +
 +
If you run into dependency errors when starting the game, be sure to re-run the <tt>mk\windoze\CopyWindowsRuntimeDlls_2010.bat</tt> batch file to copy possibly updated runtime dependency DLL's to the runtime binary folder.
 +
 +
==Reporting bugs==
 +
If you think you have run into a bug in MegaGlest, and neither reading the [http://readme.megaglest.org/ README] and [http://faq.megaglest.org/ FAQ] nor searching for it at http://bugs.megaglest.org helps, then please report a new bug at http://bugs.megaglest.org/ (one-time registration is neccessary to post).
 +
 +
When filing a bug, please provide a log of the build process of a '''full rebuild'''. With the CLI approach, run the build batch file and redirect all output to a '''log file''', such as by using:
 +
cd mk\windoze\
 +
build-mg-2010.bat n rebuild 1>%Temp%\build-mg-2010.log 2>&1
 +
@echo The build log was written to: %Temp%\build-mg-2010.log
 +
The GUI approach will always do a full rebuild if you do it as described above.
  
 
==See also==
 
==See also==
Line 33: Line 62:
 
*[[MG/Mac Compiling|Mac Compiling]]
 
*[[MG/Mac Compiling|Mac Compiling]]
 
*[[MG/FreeBSD Compiling|FreeBSD Compiling]]
 
*[[MG/FreeBSD Compiling|FreeBSD Compiling]]
 +
[[Category:MG]]
 +
[[Category:Compiling]]
 
[[Category:MG]]
 
[[Category:MG]]
 
[[Category:Compiling]]
 
[[Category:Compiling]]

Revision as of 20:18, 7 October 2012

This page explains how to compile MegaGlest for Windows.

Two approaches

Generally, there are two approaches to get your work done:

  • CLI: the automatable and fast one, using command line utilities and batch files
  • GUI: the slow and shiny one, using graphical user interfaces

The MegaGlest developers prefer the first approach, and this is also the most tested and recommended approach. You can also choose the GUI approach, which should work, but please do not expect us to support you with setting up your VC++ build environment or GUI SVN client since this is hard to support and eats a lot of time. So if you choose this approach, please do not ask for support unless you do know how this is done properly and that the issues you are running into are clearly due to a bug in the solution files or this documentation.

Prepare

  • Install Visual C++ Express 2010 as well as any service packs available for it (if any).
  • Install 7-Zip or a compatible file archiving utility.

The CLI approach

- Download and extract the build dependencies archive unless you already have it
- Update the branch you are working in with the latest subversion code
- Update the timestamp and revision no. on the
source\glest_game\facilities\game_util.cpp file
- Compile all projects from command line

  • If nothing goes wrong you will see megaglest.exe (and other binaries) in data\glest_game\ (where all the data content lives).
  • On the first run, also run the mk\windoze\CopyWindowsRuntimeDlls_2010.bat batch file to copy runtime dependency DLL's to the runtime binary folder.

The GUI approach

  • Read the above Two approaches paragraph since it provides important information on the limits of this aproach.
  • Install TortoiseSVN or a similar Subversion client and use it to check out the MegaGlest source code and game data into your local Subversion working copy.
  • Download the build dependencies archive.
  • Decompress the 7-zip compressed build dependencies archive into the source subdirectory of your Subversion working copy. You should then see a source\windows_deps\ directory with many files inside.
  • Start Visual C++ 2010 and open the main solution, located in mk\windoze\Glest_vc2010.sln
  • Perform a rebuild project.
  • If nothing goes wrong you will see megaglest.exe (and other binaries) in data\glest_game\ (where all the data content lives).
  • On the first run, also run the mk\windoze\CopyWindowsRuntimeDlls_2010.bat batch file to copy runtime dependency DLL's to the runtime binary folder.

Trouble shooting

Subversion

If you are using subversion on 64-bit Windows 7 and get error messages like The file or directory is corrupted and unreadable then that's probably because of a bug in NTFS.

Building

If your build fails, this can be due to an outdated build dependencies. Check http://sourceforge.net/projects/megaglest/files/ for when the windows_deps.7z file was last updated, and if it's more recent than the one you extracted the files in source\windows_deps\ from (or if you do not know), then recursively delete both source\windows_deps\ and source\windows_deps.7z.

When using the GUI approach, you also need to manually download the updated build dependencies archive and extract it into the source\ directory in your subversion working copy. With the CLI approach, this will be done automatically on next build.

Running

If MegaGlest crashes you should do a full rebuild. To do so with the CLI approach, instead of just running mk\windoze\build-mg-2010.bat, run mk\windoze\build-mg-2010.bat n rebuild to trigger a full rebuild.

If you run into dependency errors when starting the game, be sure to re-run the mk\windoze\CopyWindowsRuntimeDlls_2010.bat batch file to copy possibly updated runtime dependency DLL's to the runtime binary folder.

Reporting bugs

If you think you have run into a bug in MegaGlest, and neither reading the README and FAQ nor searching for it at http://bugs.megaglest.org helps, then please report a new bug at http://bugs.megaglest.org/ (one-time registration is neccessary to post).

When filing a bug, please provide a log of the build process of a full rebuild. With the CLI approach, run the build batch file and redirect all output to a log file, such as by using:

cd mk\windoze\
build-mg-2010.bat n rebuild 1>%Temp%\build-mg-2010.log 2>&1
@echo The build log was written to: %Temp%\build-mg-2010.log

The GUI approach will always do a full rebuild if you do it as described above.

See also