Why am I getting an error for UWidgetComponent?

Code:

UPROPERTY(EditAnywhere, Category = "Components")
		class UWidgetComponent* LockedOnWidget;

Error: TargetDummy.gen.cpp.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UWidgetComponent_NoRegister(void)” (_imp?Z_Construct_UClass_UWidgetComponent_NoRegister@@YAPEAVUClass@@XZ) referenced in function “void __cdecl `dynamic initializer for ‘public: static struct UECodeGen_Private::FObjectPropertyParams const Z_Construct_UClass_ATargetDummy_Statics::NewProp_LockedOnWidget’'(void)” (??__E?NewProp_LockedOnWidget@Z_Construct_UClass_ATargetDummy_Statics@@2UFObjectPropertyParams@UECodeGen_Private@@B@@YAXXZ)

UWidgetComponent | Unreal Engine Documentation

Take a look at the Module line. UWidgetComponent requires this “UMG” dependency, and it’s not added by default.

Open %YourProjectName%.build.cs and add “UMG” to the list of dependencies.

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