Gamesparks Cpp Base
The official GameSparks C++ SDK
Prerequisites (depending on which platforms you want to support)
- Android NDK
- Visual Studio
- CMake or
brew install cmakeon OSX
- python 2.x (already installed on OSX)
Running the sample
- mkdir build && cd build
- Generate the project files (contents in brackets are optional)
- OSX: cmake -GXcode <path_to_sdk>/base/build_scripts/
- Windows ( is either Win32 or Win64): cmake -G "Visual Studio 12 " <path_to_sdk>/base/build_scripts/
- Open the generated project file
- Insert your credentials into sample_configuration.h
- 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
- Copy base/src and base/include into your project directory.
- Add the source files in base/src/* (or base/src/GameSparksAll.cpp if platform is not XCode) to your project.
- Add the base/include directory to your include search paths.
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
- mkdir tests/build && cd tests/build
- Generate the project files
- OSX: cmake -GXcode ..
- Windows: cmake -G "Visual Studio .." ..
- Open the generated project in your IDE
- Edit the startup option to set the following environment variables: GAMESPARKS_API_KEY, GAMESPARKS_API_SECRET
- Compile and run GameSparksTests
Explore the API docs
This library is licensed under the Apache 2.0 License.