RTS/Compiling

From TDN

Contents

Setting up a Microsoft Visual C++ 2005 Express to compile RTS-SK

 

Author: Dennis De Marco

Contributing Authors: Tutorial pieces from Jason “TGB Boy” Cahill w/ setting up a Windows-based development environment for TGB and various posts from the GG forums (Source material sited).

April 17, 2006

Contributing Author: Brian Peal added areas for using Microsoft's Platform SDK for Windows Server 2003 R2 on July 2, 2006 and added how to include Matt Fairfaix's terrain enhancements on July 3, 2006

 

This article is designed to help you set up Microsoft Visual C++ 2005 Express to compile the RTS-SK from sources. Microsoft currently is offering the compiler for free and is a perfect fit with an indie budget in mind. Why would you need a compiler? A compiler is required in order to change the engine source code. There been several improvements to the engine made by other TDN developers that you will want to incorporate into your engine as well as bug fixes posted on forums. If you plan on purchasing the Synapse Gamming Lighting kit you will also need to learn to compile your RTS-SK kit in order to enjoy the new lighting effects the TLK offers to the RTS-SK. Parts of this tutorial have been taken from Jason Cahill's article on setting up a Windows based development environment for TGB and several forum posts here and there. This is my first Wiki article here on TDN and I hope this will help other hobbists on getting set up with the tools needed to make an executable.

This article is as accurate as humanly possible. As I wrote this article, I was replicating each step while writting it down here. If there are any errors or mistakes please feel free to tell me and update this Wiki!

Required Software

Torque RTS-SK (if you are reading this article, you should already have this)

http://www.garagegames.com/products/54

This article has been written with RTSStarterKit-1.0 in mind which is based on TGE 1.3

Torque Game Engine (you can't have downloaded RTS-SK without this)

http://www.garagegames.com/products/1

This article has been written with having purchased Torque 1.4 in mind

Free Tools (required)

Microsoft Visual C++ 2005 Express Edition & Microsoft Platform SDK:

http://msdn.microsoft.com/vstudio/express/visualc/download/

This is a fantastic offer! A full optimizing C++ compiler and engine development environment for free!

Optional Software (not required but nice to have)

Synapse Gaming Lighting Pack 1.3.5 and TLK RTS Autopatch 1.3.5

http://www.garagegames.com/products/36

The kit comes with several versions for TGE. You will want to download Synapse Gaming Lighting Pack 1.3.5 and the TLK RTS Autopatch 1.3.5. RTS-SK is based on TGE 1.3 engine. There has been some success in the forums of people converting the RTS-SK to TGE 1.4 engine, but not both TGE 1.4 / TLK 1.4. I suggest waiting for the upgrade of RTS-SK to 1.4 and Synapse autopatch for 1.4. The lessons learned here will also apply to those updates when released.

Setting Up Visual C++ Express 2005 & Platform SDK

Start by navigating to: http://msdn.microsoft.com/vstudio/express/visualc/download/

 

Image:TGB001-02-10-vc-download.jpg

 

From this page, there are three steps you need to follow (assuming you don’t have any prior beta version installed). Start by clicking the Download link and saving it to your computer. When it’s finished, you should have a file called vcsetup.exe. Run it:

 

Image:TGB001-03-vc-setup_1.png

 

Here, you can choose to send your setup experience to Microsoft. I always choose to. It can’t hurt, right? When you’ve made your decision, click Next.

 

Image:TGB001-04-vc-setup_2.png

 

Accept the license agreement, then click Next.

 

Image:TGB001-05-vc-setup_3.png

 

For building Torque-based games, you really only need the Graphical IDE. If you want additional help, above and beyond what http://msdn.microsoft.com/ provides, select Microsoft MSDN 2005 Express Edition. You do not need SQL Server Express Edition, as any online game you build will use whatever database engine your ISP provides (like mySQL or MS Access). Click Next.

 

Image:TGB001-06-vc-setup_4.png

 

I recommend the default install path. Go ahead and click Next to begin the download and install process. This will take a while, depending on whether you selected MSDN Express Edition and the speed of your internet connection…

 

Image:TGB001-07-vc-setup_5.png

 

…zzzZZZzzz… Almost there!

 

Image:TGB001-08-vc-setup_6.png

 

At the completion of the install you will see this screen:

 

Image:TGB001-09-vc-setup_7.png

 

You must register within 30 days. Once you register, the software is free to use forever after, so register now to get that hurdle out of the way (Click Register Now and follow the instructions). When you are done registering, click Exit.

Now it’s time to set up the Microsoft Platform SDK. Go back to your browser, or renavigate to: http://msdn.microsoft.com/vstudio/express/visualc/download/

Notice: The link on the Microsoft site for the Platform SDK states "This is no longer the most recent edition of the Platform SDK, please download the Windows Server 2003 R2 SDK - March 2006 Edition, (see related resources). " Here is the link:

http://www.microsoft.com/downloads/info.aspx?na=40&p=2&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&u=http%3a%2f%2fwww.microsoft.com%2fdownloads%2fdetails.aspx%3fFamilyId%3d0BAF2B35-C656-4969-ACE8-E4C0C0716ADB%26displaylang%3den

If you uses this new version make sure you follow the instructions below on editing the WinNT.h file

 

Image:TGB001-02-10-vc-download.jpg

 

This time, we are going to click the link entitled install the Microsoft Platform Software Development Kit in step 4. This will navigate you to another page of instructions:

 

Image:TGB001-11-plat_sdk.jpg

 

Click on the link to the Platform SDK which will open a new browser window. Click Download and save this file to your computer. When complete, you should have a file called PSDK-x86.exe on your machine. Run it:

 

Image:TGB001-12-plat_sdk-setup_1.png

 

Click Next.

 

Image:TGB001-13-plat_sdk-setup_2.png

 

Accept the license agreement, then click Next.

 

Image:TGB001-14-plat_sdk-setup_3.png

 

Type your name and game company’s name (or just “Home”) and click Next.

 

Image:TGB001-15-plat_sdk-setup_4.png

 

Click to select the Typical settings, then click Next.

 

Image:TGB001-16-plat_sdk-setup_5.png

 

I always accept the default location, but you may alter it if you like. When you are done, click Next.

 

Image:TGB001-17-plat_sdk-setup_6.png

 

One last speed bump. Click Next.

 

Image:TGB001-18-plat_sdk-setup_7.png

 

…zzzZZZzzz… Get ready to take a big break. This process took several hours for me to complete. Your mileage may vary. When it’s finally complete, you should see this:

 

Image:TGB001-19-plat_sdk-setup_8.png

 

OK, now that the setup is complete, let’s do the additional configuration steps recommended by Microsoft:

 

Image:TGB001-20-shell-start_menu_vs.jpg

 

Since this is the first time that Visual C++ has been started, it will take a couple of minutes to get ready. Then you should see a screen like this:

 

Image:TGB001-21-vc-config_1.jpg

 

Select the Tools menus, then Options:

 

Image:TGB001-22-vc-config_2.jpg

 

The Options dialog will appear. Now for a little tedium…

 

Image:TGB001-23-vc-config_3.jpg

 

Expand the Projects and Solutions item in the left-hand panel. Then select VC++ Directories as shown above. Now, click the on the new folder icon above the right-hand list box. A blank text edit control will appear. Into it, type: C:\Program Files\Microsoft Platform SDK\bin, as shown below:

 

Image:TGB001-24-vc-config_4.jpg

 

Then press Enter. Now, drop down the Show directories for and select Include files as shown below:

 

Image:TGB001-25-vc-config_5.jpg

 

Now, all of the entries in the right-hand list box will change. Click the new folder icon and type: c:\Program Files\Microsoft Platform SDK\Include, as shown below:

 

Image:TGB001-26-vc-config_6.jpg

 

Then, press Enter. Once again, drop the Show directories for and this time select Library files as shown below:

 

Image:TGB001-27-vc-config_7.jpg

 

And, lastly, click the new folder icon and type: C:\Program Files\Microsoft Platform SDK\Lib as shown below:

 

Image:TGB001-28-vs-config_8.jpg

 

When done, press Enter, then click OK.

Congratulations! Visual C++ Express is set up and configured. For now, close Visual C++ Express Edition.

Installing the RTS-SK

This pretty straight forward. Just double click on the executable installer that you downloaded. It will do the rest.

Loading up the project in Visual C++ 2005 Express

Alright! Now lets load up the project in Visual Studio C++ Express. Navigate where you installed your RTS-SK and find the vc7 folder. You want to double click the icon that says "RTS Full Project". This will compile the whole RTS-SK project.


Image:RTSSK-DD01.JPG


Click Next to the end until this is finished. You may get some error message at the end, just ignore it for now

Copying the DirectX8 Libraries from TGE 1.4 into RTS-SK

LINK : fatal error LNK1181: cannot open input file 'd3dx.lib'

You will get this error because the libraries for Direct X are not located in the RTS-SK. These libraries are included with the TGE 1.4 sources. To fix this, copy d3dx.lib and ddraw.lib from the Torque SDK to the RTSK. Fire up good ol' Windows file explorer for this task.


Example locations and destinations:


Copy C:\Torque\SDK\lib\directx8\d3dx.lib to C:\Torque\RTSStarterKit\lib\directx8

Copy C:\Torque\SDK\lib\directx8\ddraw.lib to C:\Torque\RTSStarterKit\lib\directx8

Source file changes that are needed to compile RTS-SK

Edit C:\Program Files\Microsoft Platform SDK\Include\winnt.h (from windows file explorer)

http://www.garagegames.com/mg/forums/result.thread.php?qt=36800

Thanks to Keith Watt for this insight from the forums you will need to change winnt.h around line 99. Navigate in Windows explorer to where you have installed the SDK. In my installation this file is located under C:\Program Files\Microsoft Platform SDK\Include\winnt.h. Double click this file and it should load up in Visual C++.

Now hit CTRL-G and 99. This is a 'Go-to line' command in Visual C++. Your looking for a line that says:


#include <basetsd.h>


This needs to be change to:

#include "basetsd.h"

Notice we we are replacing the brackets with " marks.

New: If you are using the latest version of Microsoft's Platform SDK for Windows Server 2003 R2, you will need to add the following in the WinNT.h file at line 220:


#define POINTER_64 __ptr64 //Added for RTS v1.3 upgrade to v1.4


The final should look like this:


#define POINTER_64 __ptr64 //Added for RTS v1.3 upgrade to v1.4
typedef void *PVOID;
typedef void * POINTER_64 PVOID64;


Edit winStrings.cc under RTSStarterKit/PlatformWin32 in Visual C++

Credit for this goes to Jason Swearingen from the TGB forums for this fix

Now hit CTRL-G and 195 This is a 'Go-to line' command in Visual C++. Your looking for a lines that say:


char* dStrstr(const char *str1, const char *str2) 
{
	
	return strstr(str1,str2);
  
}


and replace it with:

char* dStrstr(const char *str1, const char *str2)
{
	
return strstr((char*)str1,(char*)str2); //TCMOD: 050624 fix.  Was:  return strstr(str1,str2);
  
}

Edit TorqueDemo.rc under RTS in Visual C++

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10081

This above article I found some very good information by Ian T that helped with this section.

Find the TorqueDemo.rc file under the RTS tree in the Solution Explorer. You want to right click on that and select VIEW CODE You will want to edit the top part of this file, line 3 and line 10. (Remember CTRL-G) Change:

#include "resource.h" 

to

#include "../engine/game/resource.h" // Was #include "resource.h"

And line 10 which reads:

#include "afxres.h"

to

#include "windows.h" // Was #include "afxres.h"

Building the Project: Making the Engine!

<p> Ok! Shew that wasn't too horrible was it? Now hit CTL-ALT-F7 which is short cut for Build->Rebuild Solution from the top of Visual C++. This should now build a new executable of RTS-SK

Optional: Add Terrain enhancements

Inspired by a thread written by William Fox at http://www.garagegames.com/mg/forums/result.thread.php?qt=44135 which shows how to add terrain enhancements from Matt Fairfaix. To install the enhancements download the zip file at http://www.davox.net/terrain.zip and overwrite the files in the <RTS_ROOT>/engine/terrain

Now edit the terrSelection.cc file you just copied into the terrain directory and change line 3 to look like this:

#include "gui/guiCanvas.h" //altered for v1.4 was #include "gui/core/guiCanvas.h"

Also change terrRender.cc located in the same folder, line 18

#include "sim/frameAllocator.h" //Altered for v1.4 was #include "core/frameAllocator.h" 


Compiling... terrSelection.cc c:\rts_starter_kit-1-4_beta1\sdk\engine\terrain\terrselection.cc(3)

: fatal error C1083: Cannot open include file: 'gui/guiCanvas.h': No such file or directory

terrRender.cc c:\rts_starter_kit-1-4_beta1\sdk\engine\terrain\terrrender.cc(18)

: fatal error C1083: Cannot open include file: 'sim/frameAllocator.h': No such file or directory

I dont see where these changes work with MY hosted RTS Beta1 files author needs to clarify more on what he did to compile correctly http://www.garagegames.com/mg/forums/result.thread.php?qt=44135 does not show how to add terrain enhancements it documents creating a VS2005 TGE1.4 build and a RTS build under that TGE 1.4 solution and lists all needed edits with hosted .zip files to remove manual edit requirements altho he points to my hosted terrain.zip resource he fails to mention WHAT he is extracting this on top of

Optional: Merging TLK 1.3.5 into RTS-SK

This page comming soon. Too tired right now to finish the optional tonight