I'm Having Problems with Uuserwidgets on Ue5

I'm following a tutorial on user widgets and after I add TSubclassOf<UUserWidget> widgetClass; it gives me an error I can't figure it out:

MainPlayer.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 UECodeGen_Private::FClassPropertyParams const Z_Construct_UClass_AMainPlayer_Statics::NewProp_widgetClass''(void)" (??__E?NewProp_widgetClass@Z_Construct_UClass_AMainPlayer_Statics@@2UFClassPropertyParams@UECodeGen_Private@@B@@YAXXZ)"

the img:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Blueprint/UserWidget.h"
#include "MainPlayer.generated.h"

UCLASS()
class SURVIVAL_GAME_API AMainPlayer : public ACharacter
{
    GENERATED_BODY()

public:
    // Sets default values for this character's properties
    AMainPlayer();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;


public: 
    // Called every frame
    virtual void Tick(float DeltaTime) override;

    // Called to bind functionality to input
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;


    

public:

    //Movement and interactions

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Camera")
    UCameraComponent* myCamera;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera")
    USpringArmComponent* mySprigArm;

    UFUNCTION()
    void moveForward(float value);
    
    UFUNCTION()
    void moveRight(float value);

    UFUNCTION()
    void lookUp(float value);

    UFUNCTION()
    void lookRight(float value);

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Character")
    float movementSpeed;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Character")
    float sensitivity;

    UFUNCTION()
    void interact();

    UFUNCTION()
    void toggleInventory();
    // 

    //Variables

protected:
    UPROPERTY(EditAnywhere, Category = "Variables")
    TSubclassOf<UUserWidget> widgetClass;

    

    //
};

1 Answer

A bit late, but in case you didnt solve it yet...
My guess would be that UMG module is not added to PublicDependencyModuleNames.

You need to add it in your_progect_name.build.cs file:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore"});

add the module name to the list, in this case UMG:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG"});

It should solve the unresolved external issue.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest