Building on MSVC

From Open Surge Engine Wiki
Revision as of 05:19, 30 March 2010 by Celdecea (Talk | contribs) (more in-progress stuff)

Jump to: navigation, search

This document describes the approximate steps necessary to build the OpenSonic source in Microsoft Visual Studio. If you have no programming experience, then you may be looking for the OpenSonic binaries from this page instead.

OpenSonic is developed in C for a broad compatibility, theoretically supporting any system which can also compile the Allegro Game Programming Library. It would be helpful if you had some experience in either C or C++ or an syntax-equivalent language like (gasp) PHP.

Software you need

Before continuing on this tutorial, you will need to install a few things (unless you already know you have them). The following list attempts to describe what you need and where to get them. If the links do not work, then attempt to search for these products online.

Note that this tutorial is not going to cover how to use any of this software. For that, consult the individual documentation where necessary.

Microsoft Visual C++

The newest express edition of Microsoft's Visual C++ compiler is suggested, though this tutorial should work as far back as Visual Studio .NET 2003. There are some hacks and workarounds if you choose to use an older compiler that will be discussed later.

Microsoft Windows SDK

This one is a little tougher to choose. The above link should show a page with a table with your cryptic Development Requirement. You are probably safe choosing the one on the far left, though if you have a special compiler situation the previous versions are available for you as well. This is a sizable package that will take awhile to install.

DirectX SDK

The download for this is a bit more straightforward. The DirectX SDK release is named for the month and year it was last released (currently February 2010). This is another sizable package that will take awhile to install.

Cross Platform Make

You will need this utility to create the OpenSonic solution and project files for Visual Studio. There is a fairly straightforward install process, but note that it is a command line tool. Fortunately it is a very small package.

Subversion

This product is optional. If you wish to maintain a synchronized version of the OpenSonic source code on your computer, or if you would like to submit patches to the developer, go ahead and grab this software as well.

Setting up your Environment

  • Locate the studio command prompt
  • Make some development folders
  • Make sure the command line tools are accessible (path check)
  • Direct to the Subversion page for a brush up on checkout, revert, and update
  • building dependencies
  • Using cmake to build the solution files

Configuring the Solution

The first time you load the OpenSonic solution in Visual Studio, there are a couple of steps you should take to save time later on. These steps are optional, but the tutorial is going to assume that if you did not take them you know how to work around the issues raised. For your own sanity, you should at least check over this list.

Startup Project

Startup project in bold

Depending on your version of Visual Studio, the project files will either be on the right side of the window or on the left in the Solution Explorer box. There should be two projects in the solution:

  • ALL BUILD
  • opensonic

By default, the ALL BUILD project is bold, indicating that it will be the first project to run when the debugger starts. Go ahead and right-click on the opensonic project and click "Set as StartUp Project". If done correctly, the opensonic project is now the one in bold.

Output Directory

When the Visual Studio debugger builds the executable, by default it attempts to do so in either the Debug or Release folder. You can tell that MSVC has done this if you receive an error similar to the following:

FATAL ERROR: can't read file '...\config\sprite.def'.
Please make sure the game is installed properly.
Linker output directory

There are two ways to solve this problem. The manual way is to copy the newly built opensonic.exe file to the main opensonic folder. It will be located in a subfolder of opensonic called either Debug or Release.

The automatic way is to change where the executable is built. Right-click on the opensonic project in the Solution Explorer again, except this time click on "Properties" at the bottom of the menu. This will bring up a whole load of options pertaining to the project.

On the left, click on the Linker folder. Roughly, a linker takes a bunch of compiled code files and combines them into an EXE. In the OpenSonic project, that file is called "opensonic.exe" and you can see the output directory at the top of the Linker options.

The path should include the word Debug or Release sort of like the following:

C:\Users\celdecea\dev\opensonic\Debug\opensonic.exe

Remove the Debug or Release part so that the executable is built in the main opensonic folder:

C:\Users\celdecea\dev\opensonic\opensonic.exe

Building and Debugging

On your keyboard, hit Ctrl+Shift+B to build the application. A successful build looks somewhat like the following:

---------------------- Done ----------------------
Build: 1 succeeded, 0 failed, 1 skipped

In Progress

This document is in progress.