I don’t even begin understand what im supposed to do with these errors. Its one of those errors that I normally fix because I forgot an include statement or something but that doesnt seem to be the case this time
WidgetHelpers.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class UPanelWidget * __cdecl UWidget::GetParent(void)const " (__imp_?GetParent@UWidget@@QEBAPEAVUPanelWidget@@XZ) referenced in function "public: static class UUserWidget * __cdecl UWidgetHelpers::GetParentUserWidget(class UWidget *)" (?GetParentUserWidget@UWidgetHelpers@@SAPEAVUUserWidget@@PEAVUWidget@@@Z)
WidgetHelpers.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class UClass * __cdecl UUserWidget::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UUserWidget@@CAPEAVUClass@@XZ) referenced in function "public: static class UUserWidget * __cdecl UWidgetHelpers::GetParentUserWidget(class UWidget *)" (?GetParentUserWidget@UWidgetHelpers@@SAPEAVUUserWidget@@PEAVUWidget@@@Z)
WidgetHelpers.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class UClass * __cdecl UWidgetTree::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UWidgetTree@@CAPEAVUClass@@XZ) referenced in function "public: static class UUserWidget * __cdecl UWidgetHelpers::GetParentUserWidget(class UWidget *)" (?GetParentUserWidget@UWidgetHelpers@@SAPEAVUUserWidget@@PEAVUWidget@@@Z)
WidgetHelpers.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UUserWidget_NoRegister(void)" (__imp_?Z_Construct_UClass_UUserWidget_NoRegister@@YAPEAVUClass@@XZ) referenced in function "void __cdecl `dynamic initializer for 'public: static struct UE4CodeGen_Private::FObjectPropertyParams const Z_Construct_UFunction_UWidgetHelpers_GetParentUserWidget_Statics::NewProp_ReturnValue''(void)" (??__E?NewProp_ReturnValue@Z_Construct_UFunction_UWidgetHelpers_GetParentUserWidget_Statics@@2UFObjectPropertyParams@UE4CodeGen_Private@@B@@YAXXZ)
WidgetHelpers.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UWidget_NoRegister(void)" (__imp_?Z_Construct_UClass_UWidget_NoRegister@@YAPEAVUClass@@XZ) referenced in function "void __cdecl `dynamic initializer for 'public: static struct UE4CodeGen_Private::FObjectPropertyParams const Z_Construct_UFunction_UWidgetHelpers_GetParentUserWidget_Statics::NewProp_InputWidget''(void)" (??__E?NewProp_InputWidget@Z_Construct_UFunction_UWidgetHelpers_GetParentUserWidget_Statics@@2UFObjectPropertyParams@UE4CodeGen_Private@@B@@YAXXZ)
C:\Users\Ean\Documents\Unreal Projects\PetShip\Binaries\Win64\UE4Editor-PetShip-4150.dll : fatal error LNK1120: 5 unresolved externals
[HR][/HR]
I usually stick to blueprints when it comes to widgets for this exact reason. What Im trying to do is make a “helper library” for widgets. Just some basic things like “get the parent user widget” or “grab hud from widget” this is what I have so far
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "WidgetHelpers.generated.h"
class UWidget;
class UUserWidget;
/**
*
*/
UCLASS()
class PETSHIP_API UWidgetHelpers : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "WidgetHelper")
static UUserWidget* GetParentUserWidget(UWidget* InputWidget);
};
Thats the header. I knew it’d be kind of funky because I don’t make too many utility classes and when I do its normally a blueprint library, but UWidgetTree is something that can only be accessed via cpp so i have my hands tied. Heres the cpp file
#include "WidgetHelpers.h"
#include "Components/Widget.h"
#include "Blueprint/WidgetTree.h"
#include "Blueprint/UserWidget.h"
#include "UMG/Public/UMG.h"
UUserWidget* UWidgetHelpers::GetParentUserWidget(UWidget* InputWidget)
{
if (InputWidget) {
UWidget* nextParentWidget = InputWidget->GetParent();
UWidget* parentwidget = nextParentWidget;
if (nextParentWidget)
{
while (nextParentWidget != nullptr)
{
nextParentWidget = parentwidget->GetParent();
if (nextParentWidget)
parentwidget = nextParentWidget;
}
}
if (parentwidget)
{
UObject* parentObject = InputWidget->GetOuter();
if (parentObject)
{
UWidgetTree* tree = Cast<UWidgetTree>(parentObject);
if (tree)
{
UObject* ParentOfTree = tree->GetOuter();
if (ParentOfTree)
{
UUserWidget* userwidget = Cast<UUserWidget>(ParentOfTree);
if (userwidget)
return userwidget;
else
return nullptr;
}
}
}
else {
return nullptr;
}
}
}
return nullptr;
}
the functionality is probably skewered and needs some work but does anyone know what may be causing these strange errors? much appreciated for any help.