GameSparks C++ Base SDK

Prerequisites (depending on which platforms you want to support)

  1. Android NDK
  2. XCode
  3. Visual Studio
  4. CMake or brew install cmake on OSX
  5. python 2.x (already installed on OSX)

Running the sample

  1. mkdir build && cd build
  2. Generate the project files (contents in brackets are optional)
    • OSX: cmake -GXcode <path_to_sdk>/base/build_scripts/
    • Windows (<arch> is either Win32 or Win64): cmake -G "Visual Studio 12 [<arch>]" <path_to_sdk>/base/build_scripts/
  3. Open the generated project file
  4. Insert your credentials into sample_configuration.h
  5. Run and explore one of the samples

Note: if you get C++11 related compile errors, search for target_compile_features in base/build_scripts/CMakeList.txt and enable the lines. We have commented them out for compatibility with older cmake versions.

Note: The cmake solution is also able to create projects for Windows Phone and Windows Store. However, these are library projects only, the samples are not included yet. For completeness, here is how you generate them:

- WindowsPhone (<arch> is either Win32 or ARM): cmake -G "Visual Studio 12 [<arch>]" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.1 <path_to_sdk>/base/build_scripts/
- WindowStore (<arch> is either Win32, Win64, or ARM): cmake -G "Visual Studio 12 [<arch>]" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=8.1 <path_to_sdk>/base/build_scripts/

Integrating the SDK into your project

  1. Copy base/src and base/include into your project directory.
  2. Add the source files in base/src/ (or* base/src/GameSparksAll.cpp if platform is not XCode) to your project.
  3. Add the base/include directory to your include search paths.

Real-Time Services

Have a look at the base/samples/sample07Realtime.cpp sample and at the tutorials for the Real-Time Services. The API of the C++ SDK is very simmilar to the .NET SDK, so most of the sample code should be easy to adapt. The Real-Time Services require C++11 so make sure to update your project settings.

Static library usage (discouraged for Windows Phone / Windows Store)

If you intend to use the static libraries generated by cmake, be aware that the usage of static libraries in Windows Phone or Windows Store projects is not recommended by Microsoft. You can still use them but the dependent projects have to have the following linker flags added to them:

- Debug: /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib
- Release: /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib

These flags only apply to WindowsStore/WindowsPhone. All other targets should work out of the box.

Running the test suite

  1. mkdir tests/build && cd tests/build
  2. Generate the project files
    • OSX: cmake -GXcode ..
    • Windows: cmake -G "Visual Studio .." ..
  3. Open the generated project in your IDE
  4. Edit the startup option to set the following environment variables: GAMESPARKS_API_KEY, GAMESPARKS_API_SECRET
  5. Compile and run GameSparksTests

Next Steps

Explore the API docs, the Doxygen documentation and the Examples.