help LNK2019 errors when using EOSSDK

hi everyone, i’m working on EOS for days. I’m not good at C++, especially callbacks @:expressionless:
I’ve made some code from Lyra and EOS SamplePorject, finally got compiled
but at last got some linking problems I‘m totally disrupted …

the GameInstance looks like this:

#include "HSD_GameInstance.h"
#include "OnlineSubsystem.h"
#include "Online.h"
#include "OnlineSubsystemEOS.h"

//empty constructor
//empty Init()

void EOS_CALL UHSD_GameInstance::ConnectLoginCompleteCb(const EOS_Connect_LoginCallbackInfo* Data)
{
	//assert(Data != NULL);

	if (Data->ResultCode == EOS_EResult::EOS_Success)
	{
	}
	else if (Data->ResultCode == EOS_EResult::EOS_InvalidUser)
	{
		//may create a new user
	}
	else
	{
		UE_LOG_ONLINE(Error, TEXT("ConnectLogin failed with EOS result code (%s)"), ANSI_TO_TCHAR(EOS_EResult_ToString(Data->ResultCode)));
	}
}


void UHSD_GameInstance::ConnectLogin()
{
	//make creadential
	EOS_Connect_Credentials Credentials;
	Credentials.ApiVersion = EOS_CONNECT_CREDENTIALS_API_LATEST;
	Credentials.Type = EOS_EExternalCredentialType::EOS_ECT_DEVICEID_ACCESS_TOKEN;
	Credentials.Token = TCHAR_TO_ANSI(*FGenericPlatformMisc::GetUniqueAdvertisingId());

	//make options
	EOS_Connect_LoginOptions ConnectLoginOptions = { };
	ConnectLoginOptions.ApiVersion = EOS_CONNECT_LOGIN_API_LATEST;
	ConnectLoginOptions.Credentials = &Credentials;
	ConnectLoginOptions.UserLoginInfo = nullptr;

	// Setup a context so the callback knows what AccountId is logging in.
	std::unique_ptr<EOS_Connect_LoginCallbackInfo> Data(new EOS_Connect_LoginCallbackInfo);

	EOS_Connect_Login(ConnectHandle, &ConnectLoginOptions, Data.release(), ConnectLoginCompleteCb);
}

the build file:

using UnrealBuildTool;

public class HiSchoolDiary : ModuleRules
{
	public HiSchoolDiary(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
	
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" , "ComboGraph", "OnlineSubsystem", "OnlineSubsystemEOS" });

		PrivateDependencyModuleNames.AddRange(new string[] { });

	}
}

the errors:

1>Building 2 actions with 2 processes…
1>[1/2] Link UnrealEditor-HiSchoolDiary.dll
1> Creating library D:\GitHub\hi-schooldiary\HiSchoolDiary\Intermediate\Build\Win64\UnrealEditor\Development\HiSchoolDiary\UnrealEditor-HiSchoolDiary.suppressed.lib and object D:\GitHub\hi-schooldiary\HiSchoolDiary\Intermediate\Build\Win64\UnrealEditor\Development\HiSchoolDiary\UnrealEditor-HiSchoolDiary.suppressed.exp
1>HSD_GameInstance.cpp.obj : error LNK2019: unresolved external symbol __imp_EOS_EResult_ToString referenced in function “private: static void __cdecl UHSD_GameInstance::ConnectLoginCompleteCb(struct _tagEOS_Connect_LoginCallbackInfo const *)” (?ConnectLoginCompleteCb@UHSD_GameInstance@@CAXPEBU_tagEOS_Connect_LoginCallbackInfo@@@Z)
1>HSD_GameInstance.cpp.obj : error LNK2019: unresolved external symbol __imp_EOS_Connect_Login referenced in function “private: void __cdecl UHSD_GameInstance::ConnectLogin(void)” (?ConnectLogin@UHSD_GameInstance@@AEAAXXZ)
1>D:\GitHub\hi-schooldiary\HiSchoolDiary\Binaries\Win64\UnrealEditor-HiSchoolDiary.dll : fatal error LNK1120: 2 unresolved externals
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(45,5): error MSB3073: The command “D:\GitHub\UnrealEngine\Engine\Build\BatchFiles\Build.bat -Target=“HiSchoolDiaryEditor Win64 Development -Project="D:\GitHub\hi-schooldiary\HiSchoolDiary\HiSchoolDiary.uproject"” -Target=“ShaderCompileWorker Win64 Development -Quiet” -WaitMutex -FromMsBuild” exited with code 6.
1>Done building project “HiSchoolDiary.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

so please someone can help point a way save me out, thank you

Finally got resolved, try to record the method here

the way is integrate EOSSDK in my project, following this video
main code in OnlineSubsystemEOS.Build.cs, tell the compiler where the DLL and LIB file exist


//change this to true when you have the SDK installed
bool bSDKInstalled = true;

//update this to your SDK path it is installed
string EOSSDKVersion = "EOS-SDK-1.14.2";
string EOSPath = Path.Combine(ModuleDirectory, "EOS", EOSSDKVersion);
string EOSIncludePath = Path.Combine(EOSPath, "Include");
if (bSDKInstalled)
{
	PrivateDefinitions.Add("WITH_EOS_SDK=1");
	PublicIncludePaths.Add(EOSIncludePath);

	if (Target.Platform == UnrealTargetPlatform.Win64)
	{
		string EOSLibPath = Path.Combine(EOSPath,"Lib");
		PublicAdditionalLibraries.Add(Path.Combine(EOSLibPath, "EOSSDK-Win64-Shipping.lib"));

		//load on first call
		PublicDelayLoadDLLs.Add("EOSSDK-Win64-Shipping.dll");

		string EOSDllbPath = Path.Combine(EOSPath, "Bin");
		RuntimeDependencies.Add(Path.Combine(EOSDllbPath, "EOSSDK-Win64-Shipping.dll"));
	}
}

I think if you don’t want to put the SDK in your project, may you can do something similar in [yourgame].Build.cs

1 Like