UE4 Program linking the Engine

Is it possible to link the Engine in a Program?

I’ve seen that every other program basically has the UEBuildConfiguration.bCompileAgainstEngine = false;. However, I tried it out as true and I’ve come a long way of adding modules and include paths to my Build.cs, as well as testing out some UEBuildConfiguration values in my Target.cs, until It seemed I was going to get it right, but suddenly I came into the following error:

unresolved external symbol "bool GIsConsoleExecutable"

// which is called in the PreInit() function inside the main
INT32_MAIN_INT32_ARGC_TCHAR_ARGV()
{
	GEngineLoop.PreInit(ArgC, ArgV);
	UE_LOG(LogTestProgram, Display, TEXT("Hello World"));
	return 0;
}

I don’t know how to deal with that unresolved external, I’ve only found it in the PreInit() function as an extern bool in the LaunchEngineLoop.cpp file, and also in the Launch.cpp file as a bool declared as false. Both those files were in my include paths by default when I started out by copy pasting the BlankProgram provided.

Why I am trying to link the Engine

The main reason for this has to deal with TDD. I’m not really confortable with the testing framework provided by UE, it doesn’t fit my workflow at all. So, I thought about using my usual unit testing library within a program, but I obviously need to have the Engine classes referenced.

After overcoming a lot of compilation errors I’m now asking myself whether there is a reason for not linking the Engine in a UE Program. As of TDD, I always have my tests in another project that references the one being tested, and that’s usually the way to go for everyone.

How may I correct that error, or what would be the correct way for getting my TDD library into UE as long as I’m able to run its very own executable file?

I’m pretty sure the only way to get an executable console application in UE is within a Program, please prove me wrong if that’s not the case.

Thank you.

I was able to solve the above error and it was ofc because of my own misunderstanding of what the extern keyword was.
I finally understood it thanks to this stackoverflow post: variable declaration - When to use extern in C++ - Stack Overflow

The code now compiles with:

bool GIsConsoleExecutable; 

INT32_MAIN_INT32_ARGC_TCHAR_ARGV()
 {
     GEngineLoop.PreInit(ArgC, ArgV);
     UE_LOG(LogTestProgram, Display, TEXT("Hello World"));
     return 0;
 }

I still don’t know if it’s correct to link the engine against a program. But I finally found the answer I really wanted for Unit Testing with the library I use, thanks to this post by Wolfjagger:

and the forum link he provided with his solution: