Extending UGameEngine linker errors

I’m trying to extend the UGameEngine class and that included rewriting the init function. I’ve included all the includes (including #include “Net/NetworkProfiler.h” and #include “GameMapsSettings.h”) but the compiler still spits out these two linker errors

Error	1	error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class UClass * __cdecl UGameMapsSettings::StaticClass(void)" (__imp_?StaticClass@UGameMapsSettings@@SAPEAVUClass@@XZ) referenced in function "class UGameMapsSettings const * __cdecl GetDefault<class UGameMapsSettings>(void)" (??$GetDefault@VUGameMapsSettings@@@@YAPEBVUGameMapsSettings@@XZ)	D:\Users\Nicholas\Documents\Unreal Projects\WeirdGame 4.7\Intermediate\ProjectFiles\WeirdGameGameEngine.cpp.obj	WeirdGame


Error	2	error LNK2019: unresolved external symbol "public: void __cdecl FNetworkProfiler::EnableTracking(bool)" (?EnableTracking@FNetworkProfiler@@QEAAX_N@Z) referenced in function "public: virtual void __cdecl UWeirdGameGameEngine::Init(class IEngineLoop *)" (?Init@UWeirdGameGameEngine@@UEAAXPEAVIEngineLoop@@@Z)	D:\Users\Nicholas\Documents\Unreal Projects\WeirdGame 4.7\Intermediate\ProjectFiles\WeirdGameGameEngine.cpp.obj	WeirdGame

Does anyone know what the problemo is? :frowning:

Heres the parts of the code that calls the thingy

#if USE_NETWORK_PROFILER
	FString NetworkProfilerTag;
	if (FParse::Value(FCommandLine::Get(), TEXT("NETWORKPROFILER="), NetworkProfilerTag))
	{
		GNetworkProfiler.EnableTracking(true);
	}
#endif



	// Create game instance.  For GameEngine, this should be the only GameInstance that ever gets created.
	{
		FStringClassReference GameInstanceClassName = GetDefault<UGameMapsSettings>()->GameInstanceClass;
		UClass* GameInstanceClass = (GameInstanceClassName.IsValid() ? LoadObject<UClass>(NULL, *GameInstanceClassName.ToString()) : UGameInstance::StaticClass());

		GameInstance = ConstructObject<UGameInstance>(GameInstanceClass, this);

		GameInstance->InitializeStandalone();
	}

It’s most likely due to fact that those functions can’t be externally linked. How do you extending it if you reusing engine code? Why don’t you use Super::Init()?

I’m sorry if this doesn’t make sense, i’m pretty stupid

I wanted just to rewrite a few function calls in the init function, so i couldn’t just do super::init() i think.

extending just means making a child class right?

What i was trying to do was rewrite the part that creates the game viewport so i could put the game in a window inside the game. i thought that if i rewrote the part that calls the function to draw the game viewport and the draw game viewport function itself and then set the project to use the new ugameengine child class in DefaultEngine.ini it would work.
i probably got that all wrong. send aid

I think you are on the right direction. I recieve some errors as well. But I believe one just need to configure linker a bit. Or you can write fullpaths for #include.

As for the issue related to UGameMapsSettings adding EngineSettings to your PublicDependencyModuleNames within YourProject.Build.cs should help.

Unfortunately, you won’t have much luck with EnableTracking function afaik as it’s not exported out of Engine module. You’d have to remove that from your code or use super calls instead.

Alternatively, you could try to execute command that enables/disables netowrk profiler. Not sure if that would be possible at that point in time, during engine initialization tho.

If you want to create game viewport somewhere else, maybe you could try to singup for UGameViewportClient::OnViewportCreated delegate that’s called at the end of UGameEngine::Init and re-attach that viewport to desired location?