How would you tell if you needed a module reference?

Hi,

At around 04:00 in this lecture Sam advises that there’s a missing module reference - this was covered fairly swiftly without any explanation as to how you would really be able to tell. If I had to make a wild guess at the moment I’d be looking at the “unresolved external symbol” part of the error as a clue, but not being very familiar with C++ with Unreal yet that’s a bit of a leap.

Any chance of a bulleted list of steps (in this specific case) that would get someone from the error and non-buildable project, to the realisation that a module reference was necessary? (for example, in other videos Sam has browsed through to inherited classes, bounced out to documentation to find headers etc etc - those were kinda “steps”.)

Any info appreciated. :slight_smile:

Just did a quick Google search based on the criteria “ue5 c++ bttasks” - one of the links was to Unreal’s documentation, alebit 4.27, changed it to 5 (early access) but the module mentioned in that documentation states AIModule etc.

https://docs.unrealengine.com/4.27/en-US/API/Runtime/AIModule/BehaviorTree/Tasks/UBTTask_BlackboardBase/

I suspect I’m just look at the wrong thing, but again, this is the rabbit hole I’d end up in :slight_smile:

That would be it. That happens when the linker doesn’t find the definition of something you’re using, in this case that would be because it was defined in another module that you don’t have listed as a dependency.

The module system is specific to Unreal but here is the gist of what’s wrong.

int square(int);

int main()
{
    int value = square(3);
}

If I compile this from the command line with MSVC

cl main.cpp

I get this error

unresolved external symbol "int __cdecl square(int)" (?square@@YAHH@Z) referenced in function _main

as it compiled just fine but when it came to linking the linker didn’t find the definition. This could just be because you forgot to define it or was defined somewhere else and you didn’t tell the linker about it. If I had a square.cpp that was separately compiled into a static library then that would be

cl main.cpp square.lib

So when you get that unresolved external symbol error it’s either, you forgot to define something or you’re missing a module dependency

(Note: you don’t have to define something you don’t use, though “you” here also means generated code from Unreal)

The documentation tells you what module something is part of except here as GameplayTasks is only actually needed on Windows. Maybe other platforms already have that as a dependency or maybe the Windows code uses a different code path that has that as a dependency, I’m not sure.

1 Like

Hey Dan,

Thanks for the detailed reply, thats really helpful, appreciated.

I was going ask how we established which module was necessary, as indicated in my post above, I went in search of “BTTasks” but ended up with a different module etc. So, looking at the error;

|Error|LNK2001|unresolved external symbol public: virtual void __cdecl IGameplayTaskOwnerInterface::OnGameplayTaskActivated(class UGameplayTask &) (?OnGameplayTaskActivated@IGameplayTaskOwnerInterface@@UEAAXAEAVUGameplayTask@@@Z)|SimpleShooter|F:\Projects\Unreal\GDTV\UE5_CPP\SimpleShooter\Intermediate\ProjectFiles\BTTask_ClearBlackboardValue.cpp.obj|1||

and using your explanation, I have gone in search of “IGameplayTaskOwnerInterface” and sure enoughh I ended up with some UE5 documentation which indicated the GameplayTasks module.

Thanks again, this has been very helpful, both for this and future issues :slight_smile:

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms