LNK2019 error when compile static function declared in engine plugin

Source code:

if (UShowLoginUICallbackProxy* LoginProxy = UShowLoginUICallbackProxy::ShowExternalLoginUI(this, UGameplayStatics::GetPlayerController(this, 0)))
{
	LoginProxy->OnSuccess.AddDynamic(this, &AMainMenuGameMode::OnShowLoginProxySuccess);
	LoginProxy->OnFailure.AddDynamic(this, &AMainMenuGameMode::OnShowLoginProxyFailure);
	LoginProxy->Activate();
}

Compile error:

0>MainMenuGameMode.cpp.obj: Error : LNK2019: 无法解析的外部符号 “public: static class UShowLoginUICallbackProxy * __cdecl UShowLoginUICallbackProxy::ShowExternalLoginUI(class UObject *,class APlayerController *)” (?ShowExternalLoginUI@UShowLoginUICallbackProxy@@SAPEAV1@PEAVUObject@@PEAVAPlayerController@@@Z),函数 “public: virtual void __cdecl AMainMenuGameMode::BeginPlay(void)” (?BeginPlay@AMainMenuGameMode@@UEAAXXZ) 中引用了该符号
0>UnrealEditor-CropoutCpp.dll: Error : LNK1120: 1 个无法解析的外部命令

I enabled plugin in my editor, and added the module name “OnlineSubsystemUtils” in my build.cs, but not resolved :frowning:
I found that this error only occurs to static functions.
Has anyone resolved this?

UShowLoginUICallbackProxy has the MinimalAPI specifier, so I don’t think you can use its functions in other modules

Since this is supposed to be a blueprint async task, which are generally not used in code, since you have access to the underlying code, I would suggest binding to the same events as in UShowLoginUICallbackProxy::Activate()

GetOnlineSubystem → GetExternalUIInterface → ShowLoginUI

You don’t need much more, if ShowLoginUI returns false you should call your failure function, otherwise it should eventually call Success

Perhaps you also need to do something similar to what’s done in UShowLoginUICallbackProxy::OnShowLoginUICompleted

1 Like

Thank you so mush, I’ll try the way you taught, have a nice day :slight_smile: