Is there a way to remove/disable GoogleTest?

We have a game that includes a library that already has a version of Google Test in it.

We recently upgraded to UE5. I can get configurations including the Editor to build, but any of the standalone windows builds fail with a ton of gmock.lib linking errors like:

“bool testing::internal::g_help_flag” (?g_help_flag@internal@testing@@3_NA) already defined in gmock.lib(gtest-all.obj)

Is there a way to build without the Unreal included google test libraries? Or does someone know why our editor build would work but our standalone windows build fails?

Thanks.

Hi,

Ideally, you would modify the library you are using to not include GoogleTest in release mode, if possible, and just link the release mode library with the UE game. That would be the ideal, but if you don’t have the source (nor build) that library (or maybe you want to run the test at runtime).

I think it should be possible to workaround the problem in UE, but with some modifications to the engine. You could start by temporary modifying the file E:\UE_5.7\Engine\Source\ThirdParty\GoogleTest\GoogleTest.Build.cs to not link gmock.lib and see what relies on it in the engine, but as far as I can see by searching ‘GoogleTest’ in UE and looking at the module dependencies, they are a couple of ‘Programs’ that need it and few runtime test modules. The programs should not impact you, they are standalone that should not link your lib. For the plugins containing runtime test modules using GTest, you could disable the test modules since you should not need them to run the game. For example, the E:\UE_5.7\Engine\Plugins\Animation\RigLogic\Source\RigLogicLibTest\RigLogicLibTest.Build.cs
adds a dependency on GoogleTest like this:

			PublicDependencyModuleNames.AddRange(
				new string[]
				{
					"Core",
					"GoogleTest"
				}
			);

but this module is a test module in the RigLogic plugin, so you could disable it in
e:\UE_5.7\Engine\Plugins\Animation\RigLogic\RigLogic.uplugin by removing those lines in the file:

		{
			"Name": "RigLogicLibTest",
			"Type": "Runtime",
			"LoadingPhase": "PreDefault",
			"PlatformAllowList": [
				"Win64"
			]
		},

Something like that should work. The idea is to remove dependencies to GoogleTest module and if nothing references it, it should not be an issue anymore.

Regards,
Patrick

Thanks for the suggestion–altering GoogleTest.Build.cs doesn’t seem to do anything for me.
I tried commenting out the reference to gmock.lib in that file but it didn’t change anything.Even if I fill the file with gibberish, it doesn’t create any errors.