Why does BindKey cause Link error?



InputComponent->BindKey(EKeys::LeftShift, IE_Pressed, this, &ALedgeClimbCharacterBase::ShiftPressed);


Got these while link:



27>LedgeClimbCharacterBase.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FInputChord::FInputChord(struct FKey,bool,bool,bool,bool)" (__imp_??0FInputChord@@QEAA@UFKey@@_N111@Z) referenced in function "public: struct FInputKeyBinding & __cdecl UInputComponent::BindKey<class ALedgeClimbCharacterBase>(struct FKey,enum EInputEvent,class ALedgeClimbCharacterBase *,void (__cdecl ALedgeClimbCharacterBase::*)(void))" (??$BindKey@VALedgeClimbCharacterBase@@@UInputComponent@@QEAAAEAUFInputKeyBinding@@UFKey@@W4EInputEvent@@PEAVALedgeClimbCharacterBase@@P84@EAAXXZ@Z)
27>LedgeClimbCharacterBase.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FInputChord::FInputChord(struct FInputChord const &)" (__imp_??0FInputChord@@QEAA@AEBU0@@Z) referenced in function "public: struct FInputKeyBinding & __cdecl UInputComponent::BindKey<class ALedgeClimbCharacterBase>(struct FInputChord,enum EInputEvent,class ALedgeClimbCharacterBase *,void (__cdecl ALedgeClimbCharacterBase::*)(void))" (??$BindKey@VALedgeClimbCharacterBase@@@UInputComponent@@QEAAAEAUFInputKeyBinding@@UFInputChord@@W4EInputEvent@@PEAVALedgeClimbCharacterBase@@P84@EAAXXZ@Z)
27>LedgeClimbCharacterBase.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FInputChord::~FInputChord(void)" (__imp_??1FInputChord@@QEAA@XZ) referenced in function "public: struct FInputKeyBinding & __cdecl UInputComponent::BindKey<class ALedgeClimbCharacterBase>(struct FInputChord,enum EInputEvent,class ALedgeClimbCharacterBase *,void (__cdecl ALedgeClimbCharacterBase::*)(void))" (??$BindKey@VALedgeClimbCharacterBase@@@UInputComponent@@QEAAAEAUFInputKeyBinding@@UFInputChord@@W4EInputEvent@@PEAVALedgeClimbCharacterBase@@P84@EAAXXZ@Z)


Probably because your project is missing some dependencies:

search a MyProject.Build.cs somewhere in the MyProject\Source\MyProject\ directory and add

“SlateCore”,
“Slate”,

in the PublicDependencyModuleNames section.

4 Likes

Problem solved! Thx very much.

2 Likes

Thank you! I wasted an hour trying to figure this out! Problem solved 30 seconds after finding this thread.

Thank you so much!

I’ve got a similar issue. I added “InputCore” module to PrivateDependencyModuleNames in Build.cs

thanks! It helped me… how did you know that were those modules?

  • You can either look at the declaration of the thing with the link error in UE4s source code, and see which module it is in
  • Or you can go to Unreal Engine API Reference | Unreal Engine Documentation and find the thing you are looking for, then look at the “Module” field.
    • (just google UE4 + “the thing” and select the link titled “The Thing - Unreal Engine Documentation”

Sometimes the error doesn’t come from the function / class / struct itself but from one of its parameters / return values. So if your are certain that you have already the module for “The thing” in your build.cs, it’s a good idea to follow the links to the parameters / return values to see which one has a module you don’t have.

NOTE: If you are using the Unreal Engine API website, it is the exact same process if you want to find the include text for a specific thing. Only instead of looking at the “Module” field, you’d look at the “Include” field.

1 Like