Stuck with one error

Compilation error appears only when I add the UWidget variable. Or I declare UWidget in a function.
I re-generated the project, it did not help.
Engine version 4.26

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = “Interact”)
UWidget* WInteract;

I saved the link as a UObject and cast on UWidget then an error also appears.

If you remove UPROPERTY, everything compiles, but I need to expand the variable in BP, then I tried to transfer and write it through a function, then this also leads to the same error.

Error

unresolved external symbol “__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UWidget_NoRegister(void)” (_imp?Z_Construct_UClass_UWidget_NoRegister@@YAPEAVUClass@@anonymous_user_9674a66c) в функции “void __cdecl `dynamic initializer for ‘public: static struct UE4CodeGen_Private::FObjectPropertyParams const Z_Construct_UClass_APlace_Statics::NewProp_WInteract’'(void)” (??__E?NewProp_WInteract@Z_Construct_UClass_APlace_Statics@@2UFObjectPropertyParams@UE4CodeGen_Private@@anonymous_user_31e84eb0@@YAXXZ).

Don’t forget to add to you *.build.cs file the Module:

PublicDependencyModuleNames.AddRange( new []{ "UMG" });

And to your *.h file:

#include "Components/Widget.h"

https://docs.unrealengine.com/4.26/en-US/API/Runtime/UMG/Components/UWidget/

Thank you so much. I have not seen this in any lesson, now I will remember it forever. XD

Also, in most cases you can just forward declare classes (and other types) in header files to save on compile times.

// Telling the compiler that UWidget is a class.
// You can put this under your includes and you won't have to include the UWidget header.
// This works as long as you don't try to access something inside the UWidget class (e.g. variable/function)
class UWidget;