unresolved external symbol when using UUserWidget

Fisrt of all thanks a lot for your time. Im kinda new to c++ so i dont understand much of your are saying :c I just need to make this work and im good. I forgot to mention that im trying to use the code of this plugin (UNREAL ENGINE 4 TOOL | UMG TO SLATE (4.15 UPDATE) - YouTube) I cant run it in 4.19 bcs it only works 4.15.

If i understand your solution, i need to change my createdWidget to TWeakObjectPtr createdWidget = nullptr; ?
and also add UObject SetFlags(RF_MarkAsRootSet)

I did try your solution. Im not getting the same error now instead im getting this:

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2061	syntax error: identifier 'RF_MarkAsRootSet'	BuildingEscape	C:\repos\03_building_escape\BuildingEscape\Plugins\teste\Source\teste\Public\teste.h	30	
Error (active)	E0757	constant "RF_MarkAsRootSet" is not a type name	BuildingEscape	C:\repos\03_building_escape\BuildingEscape\Plugins\teste\Source\teste\Public\teste.h	30	

I added

#include "Runtime/CoreUObject/Public/UObject/ObjectMacros.h"

And also change the pointer lines to

UObject SetFlags(RF_MarkAsRootSet);
	TWeakObjectPtr<UUserWidget> createdWidget = nullptr;