Get SpatialOS

Sites

Menu
These are the docs for 13.1, an old version of SpatialOS. 13.3 is the newest →

Setting up a C++ worker

Prerequisites

See Requirements.

Using the C++ blank project

You can use the C++ blank project as a starting point for a C# worker; it provides a minimal example of project structure and build configuration.

Setting up a worker manually

To add a C++ worker to your project, you need to obtain the SDK through worker packages (our package management framework):

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

      {
        "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.
    • cpp-static-x86_64-gcc_libstdcpp_pic-linux - Linux 64-bit compiled as position-independent code using GCC 5.4.0 with the libstdc++ standard library.

    If you want to specify multiple packages, use multiple entries in the targets array (with different paths if desired).

    For example, if you’re using Debug and Release configurations on Windows, you 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.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums