SparCraft Windows Standalone Compilation - smithe0/ualbertabot GitHub Wiki

It is quite easy to use SparCraft as library for creating standalone Windows executables.

Headers

To use SparCraft, you must include its headers. Make sure your project includes the SparCraft/source directory, and from within your program use the following:

#include "SparCraft.h"

Compiling - Prerequisites

To compile SparCraft as a standalone Windows exe, you must have the following:

SparCraft uses the BWAPI library to obtain StarCraft data. As a convenience, SparCraft include a stripped-down version of BWAPI called bwapidata which contains only the data necessary for SparCraft to function as a standalone exe. If you do not have BWAPI installed, you can use bwapidata in its place.

Compiling - Platform Toolset Settings

An annoying part of any Visual Studio project is the platform toolset. By default, SparCraft is set to use the v90 (Visual Studio 2008) platform toolset, so that it is compatible with BWAPI 3.7.4 and all related bots. The v90 toolset requires installing Visual Studio 2008, since VS2012 does not include v90 out of the box. If you have v90 compatibility already set up, then you can compile right away, however you will not have access to any C++11 functionality, which is unavailable in v90.

The good news is, I have included with SparCraft a stripped down version of BWAPI called bwapidata which does NOT rely on the v90 toolset. You can simply switch all SparCraft projects to the v110 toolset and compile them as-is with no problems, with access to C++11 features. However, remember that the v110 version of SparCraft is NOT compatible with BWAPI-based bots.

Compiling - Step By Step Instructions

To build SparCraft.lib:

  1. Install Visual Studio 2012 (or newer)
  2. Install the Required Compilation Libraries
  3. Set BWAPI_DIR environment variable to bwapidata folder (if not using BWAPI)
  4. Launch Visual Studio 2012 (or newer)
  5. Open SparCraft/VisualStudio/SparCraft.sln
  6. Click "Do Not Upgrade"
  7. Switch all 3 projects to v110 Platform Toolset (optional if you have v90 support in VS)
  8. Change Configuration to Release (if it isn't already)
  9. Build bwapidata project (creates BWAPI.lib)
  10. Build SparCraft project (creates SparCraft.lib)

To build and run the main SparCraft.exe:

  1. Build SparCraft_main (creates SparCraft.exe)
  2. Run SparCraft/VisualStudio/Release/SparCraft.exe CONFIGFILE from a terminal