Linker error when trying to use FGameplayTagContainer

You most likely forgot to add module dependency to your module.

UE4 is modular, and what you really doing by making C++ project (or even a plugin) is adding module to the existing once in engine. The functions you calling in your code (except once that are outside UE4 APIs) exist in other modules and in order for UBT to properly link them it needs information on which modules you using, as well information for engine which modules to load first when your module is load. So when you use function or type in specific module you need to add dependency to your module build script (*.build.cs file).

First to check which module to add you need to look in to API reference of type or function you use:

You can see on bottom module and header file in which type is declered, in this case module name is “GameplayTags”. You can also check module name by looking on header file path, it usually 2nd directory name after “Source”:

Runtime/GameplayTags/Classes/GameplayTagContainer.h

So open *.build.cs file in your module source files and search for this line:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore"});

And add module to that array by adding comma and module name in quatation marks after last dependent module declared

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "GameplayTags"});
16 Likes