Problem linking GameLift server SDK in Unreal Engine 4.20 project

I am trying to include the GameLift SDK plugin in an Unreal Project that previously compiled fine with UE 4.19. However, I am getting these linker errors in Development Server configuration after upgrading to 4.20:


LNK2005 "public: __cdecl Aws::GameLift::Server::Model::GameSession::~GameSession(void)" already defined in Module.GameLiftServerSDK.cpp.obj (aws-cpp-sdk-gamelift-server.lib)
LNK2005 "public: __cdecl Aws::GameLift::Server::Model::GameSession::GameSession(class Aws::GameLift::Server::Model::GameSession const &)" already defined in Module.GameLiftServerSDK.cpp.obj (aws-cpp-sdk-gamelift-server.lib)

I tried recompiling the GameLift server SDK plugin, but I’m still getting the same. Looking at the errors themselves, indeed it looks like the constructor and destructor for GameSession mentioned in the errors are defined in GameLiftServerSDK/Public/aws/gamelift/server/model/GameSession.h. I assume the same functions are present in the lib/dll for the plugin, and that’s why I have the duplicates. But it seems nothing changed from the last time compilation was successful (other than UE version).

I am using Visual Studio 2017. Any ideas what could be wrong?

1 Like

Superficially it seems that you have mismatched headers and dlls (ie you rebuilt the DLL but are using old headers), I would double check that the included headers are from the SDK location you built the DLL from etc.

Potentially more likely is that you’re hitting issues with the current Gamelift unreal plugin, which I can only apologize for as it needs to be refreshed to match the Unreal 4.20/4.21 releases. We intend to refresh our unreal plugin very soon, but ETA of release is unknown at this time.

If this is a blocking issue for you, please reach out via AWS support and we can discuss how we can help mitigate.

The other alternative is to integrate directly with the Server SDK as the unreal plugin is really just a very thin wrapper around the GameLift Server SDK.

https://forums.awsgametech.com/t/unreal-engine-4-20-compatibility/5624/1

Hi @Pip,

I have exactly the same issue with the last SDK update for Unreal 4.20.3.

Do you know what’s the issue ?

Régis

Hi @Pip,

I have the same issue as this.
I had no problem with UE4.20 and ServerSDK 3.1.7,
but this issue occurred when I upgrade ServerSDK to 3.3.0 .
Could you please investigate this?

I moved the implementation of the two functions from GameSession.h to any of cpp file(e.g., GameLiftServerAPI.cpp,
and succeeded to build my game server.

Hello @LittleDiff!

Desperate for an answer, I am now attempting your solution as you had success with these as you said.

What are the specifics that you have done? Did you edit GameSession.h on the GameLift Server SDK C++ source before building the DLL and LIB files? Are there more steps?

Would like some clarity here.

Thank you so much and I appreciate your help!

Has anyone found a solution to this yet?

Hello @Pip , any updates on this?

I’m encountering the same problem.

@IvkoStanilov’s errors occurs with me also in this setup:

  • Successfully built .dll and .lib files with VS 2017
  • GameLift Server SDK 3.1.7
  • UE 4.21
    Additionally, I tried upgrading my GameLift Server SDK to 3.3.0 and it gives me additional errors. Logs are as follows:

------ Build started: Project: My, Configuration: Development_Server x64 ------Building 1 action with 4 processes... [1/1] MyServer.exe
aws-cpp-sdk-gamelift-server.lib(aws-cpp-sdk-gamelift-server.dll) : error LNK2005: "public: __cdecl Aws::GameLift::Server::Model::GameProperty::~GameProperty(void)" (??1GameProperty@Model@Server@GameLift@Aws@@QEAA@XZ) already defined in GameLiftServerSDK.cpp.obj
aws-cpp-sdk-gamelift-server.lib(aws-cpp-sdk-gamelift-server.dll) : error LNK2005: "public: __cdecl Aws::GameLift::Server::Model::GameSession::~GameSession(void)" (??1GameSession@Model@Server@GameLift@Aws@@QEAA@XZ) already defined in GameLiftServerSDK.cpp.obj
aws-cpp-sdk-gamelift-server.lib(aws-cpp-sdk-gamelift-server.dll) : error LNK2005: "public: __cdecl Aws::GameLift::Server::Model::GameSession::GameSession(class Aws::GameLift::Server::Model::GameSession const &)" (??0GameSession@Model@Server@GameLift@Aws@@QEAA@AEBV01234@@Z) already defined in GameLiftServerSDK.cpp.obj
aws-cpp-sdk-gamelift-server.lib(aws-cpp-sdk-gamelift-server.dll) : error LNK2005: "public: __cdecl Aws::GameLift::Server::Model::Player::Player(void)" (??0Player@Model@Server@GameLift@Aws@@QEAA@XZ) already defined in GameLiftServerSDK.cpp.obj
Creating library F:\Git\ProjectFolder\Binaries\Win64\MyServer.lib and object F:\Git\ProjectFolder\Binaries\Win64\MyServer.exp
F:\Git\ProjectFolder\Binaries\Win64\MyServer.exe : fatal error LNK1169: one or more multiply defined symbols found
UnrealBuildTool : error : UBT ERROR: Failed to produce item: F:\Git\ProjectFolder\Binaries\Win64\MyServer.exe
...
Done building project "My.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 1 skipped ==========

I tried a clean build / rebuild. Still the same. Made sure the DLLs are consistent. What gives?!

Yes, you are right.
I modified GameSession.h and GameLiftServerAPI.cpp before starting to build them.
I couldn’t find out why the inline definitions are troubling on compiling(inline functions should be compiled with no problem. Maybe any wrong compiling option?).

Anyway,
I removed the definitions of the two functions(i.e., I leaved only the declarations of them) in GameSession.h, and added the definitions in GameLiftServerAPI.cpp, because the error message is literally complaining ‘multiple definition’, and the error was gone. (*)

This tends to happen when you are building an Unreal Engine project with both the GameLiftServerSDK plugin and the AWS SDK. To avoid the building of both, I would recommend modifying your project’s build file like so to only build certain plugins based on the build target

if (Target.Type == TargetRules.TargetType.Client)
{
        PublicDependencyModuleNames.Add("GameLiftClientSDK"); // or whatever you called the module
}
if (Target.Type == TargetRules.TargetType.Server)
{
        PublicDependencyModuleNames.Add("GameLiftServerSDK");
}

I warn people however that it is not recommended to call GameLift and other AWS services directly from the client. You are better off making a client service using Lambda and API Gateway for example that handles all the communication with the AWS services for you, then calling these APIs through http requests.

2 Likes

This was exactly my issue, it’s also probably helpful to add definitions to disable the relevant ifdef’s for the dependency that is being excluded. This will keep the rest of the codebase happy, for example:

if (Target.Type == TargetRules.TargetType.Client)
{
    PublicDependencyModuleNames.Add("GameLiftClientSDK");
    PublicDefinitions.Add("WITH_GAMELIFT=0");
}
else if (Target.Type == TargetRules.TargetType.Server)
{
    PublicDependencyModuleNames.Add("GameLiftServerSDK");
    PublicDefinitions.Add("WITH_GAMELIFTCLIENTSDK=0");
}
1 Like

I’m reviving this thread because I’m now trying to figure out this exact same issue, and this seems to be the only thread discussing this specifically. Firstly, aside from this linker error, everything else is running fantastically. My client is simple and not using the SDK, I’m using an API Gateway and Lambda for everything which is working really nicely. My server is using the GameLift Server SDK, and I’ve had that complete and working nicely for a few weeks.

My issue is that I specifically want my dedicated server to have access to other AWS services, to start with I want it to be able to write (for example) the user generated objects to S3, The objects are easy, they’re already serialised and written to disk, I’ve even gone as far as read them back in as a byte stream, because I was just about to try and upload them through the Gateway since that has worked for everything else, but doing this from within an existing VPC just feels insane,

However, this is where I hit the wall. I’m got my AWS SDK built, my plugin setup, but as soon as it comes times to build my plugins:
fatal error LNK1169: one or more multiply defined symbols found
What’s bizarre to me is that I have two seperate plugins side-by-side, if I disable my client plugin then the server plugin builds fine, but if I enable my client plugin, it’s the server plugin that dies… Now that I’ve found this thread, I’m going to try what @LittleDiff suggested, because frankly I’ve tried almost everything else :stuck_out_tongue: