These are the docs for 13.8, an old version of SpatialOS.
The docs for this version are frozen: we do not correct, update or republish them.
14.5 is the newest →
Setting up the Worker SDK in C
Requirements
Prerequisites
Follow the SpatialOS tools installation guide
(Windows
/
macOS
/
Linux). This is a prerequisite for using the Worker SDK.
Supported compilers and runtimes
The Worker SDK in C works with any C compiler that supports the ANSI C standard, or any other
language which is designed to work with C libraries. We compile native libraries which target at
least the following toolchains and platforms:
Windows: Microsoft Visual Studio 2015 Update 3 and above.
macOS: Xcode 10 targeting OS X Yosemite (10.10) and above.
On Windows, if you choose to use a worker package which has been compiled with the /MD or /MDd
flags (multithreaded dynamic, and multithreaded dynamic debug), then any system which uses these
libraries (including client systems) will also require
Visual C++ Redistributable for Visual Studio 2015.
Usually, MSVC projects will use the multi-threaded dynamic runtime (/MD) in the Release configuration,
and the multi-threaded dynamic debug runtime (/MDd) in the Debug configuration.
iOS and Android support is currently in alpha. In particular,
iOS apps using SpatialOS do not yet support IPv6 only networks. However, this will be resolved in the near future.
Packages
You can obtain packages through worker packages,
our package management framework. You can specify these packages in a spatialos_worker_packages.json or download
them manually by running spatial package get worker_sdk <package_name> <version> <destination zip> (for
example: spatial package get worker_sdk c-static-x86_64-msvc_md-win32 13.6.2 windows.zip).
The Worker SDK in C is a native library, so it is compiled for a large variety of platforms, architectures and configurations.
Each package contains native libraries built for a particular configuration, plus the required header files. For more information, see
Building a worker.
The tables below list all the packages you can retrieve, relevant to the Worker SDK for C:
Assuming you have a worker set up with a
worker configuration file, you can obtain
the relevant worker package as follows:
Assuming that worker_dir is <project_root>/workers/<your_worker>, add the following
configuration within <worker_dir>/spatialos_worker_packages.json to download the header files and
libraries to <worker_dir>/dependencies/worker_sdk:
You can specify multiple packages at once as multiple entries in the targets array with
different paths if desired. For example, if you’re building a worker using C and C++, you can download
both the Multithreaded Dynamic (MD) and Multithreaded Dynamic Debug (MDd) packages, and point
the MSVC project to link against the different packages depending on the configuration (Debug /
Release). You can also specify packages for macOS and Linux so that you can use them when building
on other platforms.
In this example, the spatialos_worker_packages.json will look similar to:
In a terminal, cd to <worker_dir> and run
spatial package unpack (which is done automatically by spatial worker build if
unpack dependencies
is specified in the build.json).
This will unpack the worker package specified above into the sub-directory. The downloaded
worker package will be compatible with the SpatialOS SDK version used for your application
(specified in <root>/spatialos.json under sdk_version).