Get SpatialOS

Sites

Menu

Setting up a C++ worker

Using the C++ blank project

The C++ blank project provides a minimal example of project structure and build configuration for C++ workers. It is the best way to get something working quickly and easily. You shouldn’t need to do any additional setting up if you choose to use it.

Obtaining the SDK

In case you want to start from scratch, you can obtain the SDK through worker packages, our package management framework.

You can obtain the relevant worker package as follows:

  1. Add the following configuration within <root>/workers/<your_worker>/spatialos_worker_packages.json to download the header files and libraries to link against:

      {
        "targets": [
          {
            "path": "worker_sdk",
            "type": "worker_sdk",
            "packages": [
              {
                "name": "<package>"
              }
            ]
          }
        ]
      }
    

    The supported options for <package> are currently:

    • cpp-static-x86-msvc_md-win32 - Windows 32-bit compiled using MSVC (with /MD runtime).
    • cpp-static-x86_64-msvc_md-win32 - Windows 64-bit compiled using MSVC (with /MD runtime).
    • cpp-static-x86_64-msvc_mdd-win32 - Windows 64-bit compiled using MSVC (with /MDd runtime).
    • cpp-static-x86_64-msvc_mt-win32 - Windows 64-bit compiled using MSVC (with /MT runtime).
    • cpp-static-x86_64-msvc_mtd-win32 - Windows 64-bit compiled using MSVC (with /MTd runtime).
    • cpp-static-x86_64-clang_libcpp-macos - macOS 64-bit compiled using Xcode 8.
    • cpp-static-x86_64-gcc_libstdcpp-linux - Linux 64-bit compiled using GCC 5.4.0 with the libstdc++ standard library.

    Multiple packages can be specified at once as multiple entries in the targets array with different paths if desired. For example, when using Debug and Release configurations on Windows, we can download both the /MD and /MDd builds of the C++ worker SDK, and point the MSVC project to the correct lib directories for each configuration. The spatialos_worker_packages.json will look similar to:

      {
        "targets": [
          {
            "path": "worker_sdk/windows/debug",
            "type": "worker_sdk",
            "packages": [
              {
                "name": "cpp-static-x86_64-msvc_mdd-win32"
              }
            ]
          },
          {
            "path": "worker_sdk/windows/release",
            "type": "worker_sdk",
            "packages": [
              {
                "name": "cpp-static-x86_64-msvc_md-win32"
              }
            ]
          }
        ]
      }
    
  2. In a terminal, cd to the directory containing your spatialos_worker_packages.json and run spatial worker package unpack.

    This will unpack the worker SDK (type) for the specified language and platform into the specified sub-directory (path). The downloaded worker package will be compatible with the SpatialOS SDK version used for your application (specified in <root>/spatialos.json under sdk_version).

Head to Compiling a C++ worker for the next steps.

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums