Details how we integrated Ruyi C++ SDK with Unreal Engine 4.
Also see packaging instructions.
- See prerequisites for C++ SDK
- Unreal Engine 4 (4.18+ tested, 4.20+ recommended since VS 2017 is default), Compiled version
Here we detail adding the precompiled SDK binary to the UE4 demo. The same process can be followed for other UE4 projects, substituting PlatformerGame
with the name of your project.
-
Download the latest SDK release
-
The C++ SDK contains two folders: include/ and lib/. Copy them to your UE4 module source folder. E.g.:
Source/PlatformerGame/RuyiSDK/include
andSource/PlatformerGame/RuyiSDK/lib
. -
Open
Source/PlatformerGame/PlatformerGame.Build.cs
-
Add
using System.IO;
to the top of the file. Bind lib path with:private string ModulePath { get { return ModuleDirectory; } } private string LibPath { get { return Path.GetFullPath(Path.Combine(ModulePath, "RuyiSDK/lib/")); } }
-
Inside the constructor
public PlatformerGame(ReadOnlyTargetRules Target)
add SDK paths to thePublicIncludePaths
property:PublicIncludePaths.AddRange( new string[] { "PlatformerGame/RuyiSDK/include", "PlatformerGame/RuyiSDK/include/Generated/CommonType", });
-
Enable RTTI and exceptions for boost:
bUseRTTI = true; bEnableExceptions = true; Definitions.Add("BOOST_ALL_DYN_LINK");
-
Specify libraries:
PublicAdditionalLibraries.Add(Path.Combine(LibPath, "RuyiSDK.lib")); PublicAdditionalLibraries.Add(Path.Combine(LibPath, "zmq", "libzmq.lib")); PublicAdditionalLibraries.Add(Path.Combine(LibPath, "boost", "boost_chrono-vc141-mt-1_64.lib")); PublicAdditionalLibraries.Add(Path.Combine(LibPath, "boost", "boost_date_time-vc141-mt-1_64.lib")); PublicAdditionalLibraries.Add(Path.Combine(LibPath, "boost", "boost_system-vc141-mt-1_64.lib")); PublicAdditionalLibraries.Add(Path.Combine(LibPath, "boost", "boost_thread-vc141-mt-1_64.lib"));
-
Copy runtime libraries
lib/zmq/libzmq.dll
andlib/boost/*.dll
to the build output folder:Binaries/Win64
. -
Open your project with Unreal Engine 4 Editor. Click File -> Refresh Visual Studio Project (or right-click PlatformerGame.uproject file and click Generate visual studio project file). Wait for it to finish, then reload your Visual Studio project and you will find include and lib folders in Solution Explorer (click View -> Solution Explorer).
-
When using SDK functions, include
RuyiSDK.h
and use apprpropriate namespaces (likeRuyi::RuyiSDK
). Refer to the SDK documentation for API details. -
Build your project.
You can also use a binary built from the SDK source.
-
From
RuyiSDKCpp\bin\Release
, copy the include and lib folders to your main module (e.g.Source/PlatformerGame/RuyiSDK/
). -
Follow remainder of instructions from "Using SDK Binary"
UE4 supports several version of Visual Studio. Starting with 4.20 VS 2017 is the default.
When VS 2017/v141 is not the default, you can generate VS project files on command line with -2017
param:
UnrealBuildTool.exe -projectfiles -project="C:/XXX.uproject" -game -engine -progress -2017
If it stills use v140 toolset:
- Open Registry Editor by running
regedit
- Locate
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VC7
- Normally there is "14.0" and "15.0" keys. Delete "14.0". And, if it doesn't exist already, create "15.0" with value data of the install path of Visual Studio 2017 (e.g.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC
).
- Re-generate the project files on command line (using
-2017
again) - Open the sln project file, compile it, it should work fine.
- You can add the "14.0" key back after you generate the project files
To target v140, you'll need to rebuild our SDK and all it's dependencies.
-
Build SDK Binary, making sure all binaries target v140:
-
Follow remainder of instructions from "Building SDK Binary"
-
Since the SDK uses boost, you may encounter
error LNK2038: mismatch detected for 'boost__type_index__abi': value 'RTTI is used'
. You can solve this by addingbUseRTTI = true;
to xxxx.build.cs. -
Similarly:
Error C4577: 'noexcept' used with no exception handling mode specified
. You can solve this by addingbEnableExceptions = true;
to xxx.build.cs. -
If you encounter:
RuyiSDK.lib(RuyiNetService.obj) : error LNK2001: unresolved external symbol __std_reverse_trivially_swappable_1 RuyiSDK.lib(RuyiNetVideoService.obj) : error LNK2001: unresolved external symbol __std_reverse_trivially_swappable_1 RuyiSDK.lib(RuyiNetGamificationService.obj) : error LNK2001: unresolved external symbol __std_reverse_trivially_swappable_1 D:\usr\sample_ue4_demo\Binaries\Win64\UE4Editor-RuyiSDKDemo.dll : fatal error LNK1120: 1 unresolved externals
This is caused by UE4 using v140 toolset while our C++ SDK binary is compiled with v141. You need to do one of: