Platform Implementation for EOS

Guidelines and references for implementing EOS SDK on consoles

To run the Epic Online Services (EOS) SDK, you must follow several prerequisite steps in your project's linking, packaging, and loading processes to ensure that your target platform loads and runs the EOS run-time. This page provides generic information about those processes, while the pages listed under Platform-Specific Documentation provide more specific information about each platform's needs. This page also includes information about how to use the Unreal Build System with EOS SDK.

For documentation regarding the EOS SDK and consoles (PlayStation, Xbox, Nintendo Switch, etc), you must configure your organization access and the documentation will be part of the SDK drop after First Party approval.

Thread Safety

The EOS SDK is not considered thread safe.

You should make all calls on the same thread. Some functions assert and crash if called from different threads.

Building

All EOS SDK headers include the eos_base.h header, but some platforms need additional setup before you can call eos_base.h. Each platform needing additional setup mentions this within the Platform-Specific Documentation and has a <Platform>/eos<Platform>base.h file for this additional setup.

Using eos_platform_prereqs.h

The EOS SDK provides the eos_platform_prereqs.h header to support cross-platform development. To use eos_platform_prereqs.h, add the EOS_BUILD_PLATFORM_NAME macro when building applications that need to include a specific platform.

Include the eos_platform_prereqs.h header before any other EOS SDK headers.

For example, if you are using the Unreal Build System, add the following code to your <Project>.Build.cs file:

if (!Target.IsInPlatformGroup(UnrealPlatformGroup.Windows) &&
    !Target.IsInPlatformGroup(UnrealPlatformGroup.Unix) &&
    !Target.IsInPlatformGroup(UnrealPlatformGroup.Apple) &&
    !Target.IsInPlatformGroup(UnrealPlatformGroup.Android))
{
    AppendStringToPublicDefinition("EOS_BUILD_PLATFORM_NAME",
        Target.Platform.ToString());
}

Add the following #includes when using the different EOS interfaces:

#include "eos_platform_prereqs.h"
#include "eos_sdk.h"
#include "eos_[interface]_types.h"

For eos[interface]types.h, replace [interface] with the interface you are using:

#include "eos_friends_types.h"
#include "eos_auth_types.h"
#include "eos_lobby_types.h"

Custom Cross-Platform Example

If eos_platform_prereqs.h doesn't fit with the project's build system, it can reference macros provided by custom compilers. For example:

#if defined(__THECOMPILER__)
#include "ThePlatform/eos_ThePlatform_base.h"
#elif defined(__SOMECOMPILER__)
#include "SomePlatform/eos_SomePlatform_base.h"
#endif
#include "eos_sdk.h"
#include "eos_friends_types.h"

Single Platform Example

When a single platform needs additional #includes for the EOS Friends Service, use the following:

#include "ThePlatform/eos_ThePlatform_base.h"
#include "eos_sdk.h"
#include "eos_[interface]_types.h"

For eos[interface]types.h, replace [interface] with the interface you are using:

#include "eos_friends_types.h"
#include "eos_auth_types.h"
#include "eos_lobby_types.h"

Linking

When linking your project, you need to add the link-time library for EOS SDK to the link command for your project. For most platforms, the run-time library will need to be loaded manually as well.

Linking with Unreal Build System

If you are using Unreal Engine, the Unreal Build Tool will manage the linking and packing of your library if you follow these steps in the <Project>.Build.cs file:

  1. Add the library link-time name to PublicAdditionalLibraries.

  2. Add the library link-time file to RuntimeDependencies.

As an example, your <Project>.Build.cs file should include code similar to the following:

PublicAdditionalLibraries.Add(LibraryLinkName);
string RuntimeLibrarySourcePath = Path.Combine(SDKBinariesDir, RuntimeLibraryFileName);
string RuntimeLibraryTargetPath = Path.Combine(ProjectBinariesDir, RuntimeLibraryFileName);
RuntimeDependencies.Add(RuntimeLibraryTargetPath, RuntimeLibrarySourcePath, StagedFileType.NonUFS);

Packaging

In most cases, placing the run-time library for EOS SDK in the same directory as the game executable will ensure that the game can find it at run-time. Some platforms have specific directories you need to place their libraries in. Review the platform-specific pages for more details.

Loading

Some platforms require you to load the dynamic module for EOS SDK explicitly at runtime. Refer to the platform-specific pages for details on how to do this with each platform. If no process is noted, then explicit loading is not necessary.

Loading with Unreal

As long as you use the Unreal Build Tool to set up the packaging of your game, the same process can be used on all platforms. Use FPlatformProcess::GetDllHandle to load the module and FPlatformProcess::FreeDllHandle to unload the module.

Memory Functions

The EOS SDK can use any memory management system you develop when you provide custom allocators through EOS_InitializeOptions. If allocators are not provided, the EOS SDK uses standard allocators, such as malloc, free, and realloc.

However, consoles are the exception and require custom allocators. Memory management on consoles is a complex and highly platform-dependent process. To prevent any unexpected behavior, consoles are required to provide these custom allocators to ensure all memory management is by the application. For a detailed explanation of how memory management works for your current platform, please refer to the first party SDK documentation.

Memory Functions with Unreal

When using Unreal Engine with the EOS SDK, the allocators provided to EOS_InitializeOptions can be mapped to FMemory::Malloc, FMemory::Realloc, and FMemory::Release.

Platform-Specific Documentation

The following links provide guidelines for the above processes on specific platforms: