problem creating component of type UWidgetInteractionComponent

Hi guys, I recently did studying the player’s interaction with widgets that are in the scene and discovered the ready-made tool UWidgetInteractionComponent. I implemented the logic of the interaction through blueprints. I simply added the component to the hierarchy and used it.

After that, I wanted to write this code in C ++, but I had problems.
When I add the header “#include” Components / WidgetInteractionComponent.h "to the CameraPawn.cpp file and add to CameraPawn.h a variable of the type UWidgetInteractionComponent * marked as UPROPERTY, Visual Studio gives me a strange output to which I do not know how to react and solve the problem :


1>------ Rebuild All started: Project: Blockade900, Configuration: Development_Editor x64 ------
1>Cleaning Blockade900Editor and UnrealHeaderTool binaries...
1>Using 'git status' to determine working set for adaptive non-unity build (D:\Unreal Engine\Unreal projects\Blockade900).
1>Creating makefile for Blockade900Editor (no existing makefile)
1>Parsing headers for Blockade900Editor
1> Running UnrealHeaderTool "D:\Unreal Engine\Unreal projects\Blockade900\Blockade900.uproject" "D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\Blockade900Editor\Development\Blockade900Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="C:\Users\Denis\AppData\Local\UnrealBuildTool\Log_UHT.txt" -installed
1>Reflection code generated for Blockade900Editor in 5,3156588 seconds
1>Building Blockade900Editor...
1>Using Visual Studio 2019 14.26.28806 toolchain (D:\Visual Studio\VC\Tools\MSVC\14.26.28801) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Building 56 actions with 8 processes...
1> [1/56] Default.rc2
1> [2/56] Default.rc2
1> [3/56] SharedPCH.Engine.ShadowErrors.cpp
1> [4/56] InteractComponent.cpp
1> [5/56] TemperatureVolumeBox.cpp
1> [6/56] Interactable.cpp
1> [7/56] DissolveObjectsComponent.cpp
1> [8/56] PlayerCharacter.cpp
1> [9/56] AIPlayerCharacterController.cpp
1> [10/56] CameraPawn.cpp
1> [11/56] FoodItem.cpp
1> [12/56] InventoryComponent.cpp
1> [13/56] Item.cpp
1> [14/56] SurvivalSystemComponent.cpp
1> [15/56] InvItemInfo.cpp
1> [16/56] ManPickup.cpp
1> [17/56] BlockadeGameState.cpp
1> [18/56] DissolveComponent.cpp
1> [19/56] InteractableInterface.cpp
1> [20/56] TemperatureVolumeSphere.cpp
1> [21/56] Ladder.cpp
1> [22/56] FunctionLibrary.cpp
1> [23/56] Module.LoadingScreen.gen.cpp
1> [24/56] TemperatureVolumeBase.cpp
1> [25/56] TemperatureVolumeSphere.gen.cpp
1> [26/56] Blockade900.init.gen.cpp
1> [27/56] BlockadePlayerController.cpp
1> [28/56] BlockadePlayerController.gen.cpp
1> [29/56] BlockadeGameState.gen.cpp
1> [30/56] PlayerMovementComponent.cpp
1> [31/56] CameraPawn.gen.cpp
1> [32/56] DissolveComponent.gen.cpp
1> [33/56] Blockade900.cpp
1> [34/56] AIPlayerCharacterController.gen.cpp
1> [35/56] FoodItem.gen.cpp
1> [36/56] DissolveObjectsComponent.gen.cpp
1> [37/56] Interactable.gen.cpp
1> [38/56] FunctionLibrary.gen.cpp
1> [39/56] InteractableInterface.gen.cpp
1> [40/56] InventoryComponent.gen.cpp
1> [41/56] InteractComponent.gen.cpp
1> [42/56] TemperatureVolumeBox.gen.cpp
1> [43/56] TemperatureVolumeBase.gen.cpp
1> [44/56] ManPickup.gen.cpp
1> [45/56] PlayerMovementComponent.gen.cpp
1> [46/56] Ladder.gen.cpp
1> [47/56] Item.gen.cpp
1> [48/56] PlayerCharacter.gen.cpp
1> [49/56] InvItemInfo.gen.cpp
1> [50/56] SurvivalSystemComponent.gen.cpp
1> [51/56] UE4Editor-Blockade900.lib
1> Creating library D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\UE4Editor\Development\Blockade900\UE4Editor-Blockade900.lib and object D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\UE4Editor\Development\Blockade900\UE4Editor-Blockade900.exp
1> [52/56] UE4Editor-Blockade900.dll
1> Creating library D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\UE4Editor\Development\Blockade900\UE4Editor-Blockade900.suppressed.lib and object D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\UE4Editor\Development\Blockade900\UE4Editor-Blockade900.suppressed.exp
1>CameraPawn.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UWidgetInteractionComponent_NoRegister(void)" (__imp_?Z_Construct_UClass_UWidgetInteractionComponent_NoRegister@@YAPEAVUClass@@XZ) referenced in function "void __cdecl `dynamic initializer for 'public: static struct UE4CodeGen_Private::FObjectPropertyParams const Z_Construct_UClass_ACameraPawn_Statics::NewProp_WidgetInteraction''(void)" (??__E?NewProp_WidgetInteraction@Z_Construct_UClass_ACameraPawn_Statics@@2UFObjectPropertyParams@UE4CodeGen_Private@@B@@YAXXZ)
1>D:\Unreal Engine\Unreal projects\Blockade900\Binaries\Win64\UE4Editor-Blockade900.dll : fatal error LNK1120: 1 unresolved externals
1> [53/56] Module.LoadingScreen.cpp
1> [54/56] UE4Editor-LoadingScreen.lib
1> Creating library D:\Unreal Engine\Unreal projects\Blockade900\Plugins\LoadingScreen\Intermediate\Build\Win64\UE4Editor\Development\LoadingScreen\UE4Editor-LoadingScreen.lib and object D:\Unreal Engine\Unreal projects\Blockade900\Plugins\LoadingScreen\Intermediate\Build\Win64\UE4Editor\Development\LoadingScreen\UE4Editor-LoadingScreen.exp
1> [55/56] UE4Editor-LoadingScreen.dll
1> Creating library D:\Unreal Engine\Unreal projects\Blockade900\Plugins\LoadingScreen\Intermediate\Build\Win64\UE4Editor\Development\LoadingScreen\UE4Editor-LoadingScreen.suppressed.lib and object D:\Unreal Engine\Unreal projects\Blockade900\Plugins\LoadingScreen\Intermediate\Build\Win64\UE4Editor\Development\LoadingScreen\UE4Editor-LoadingScreen.suppressed.exp
1>D:\Visual Studio\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(54,5): error MSB3073: The command "chcp 65001 >NUL && "D:\Unreal Engine\Versions\UE_4.25\Engine\Build\BatchFiles\Rebuild.bat" Blockade900Editor Win64 Development -Project="D:\Unreal Engine\Unreal projects\Blockade900\Blockade900.uproject" -WaitMutex -FromMsBuild" exited with code -1.
1>Done building project "Blockade900.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

and a list of errors, says that I now have 13348 of them.
Can anyone help me figure out what the problem is?

Begin of CameraPawn.h:


#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "CameraPawn.generated.h"

DECLARE_LOG_CATEGORY_EXTERN(ZoomLog, Log, All);


class USpringArmComponent;
class UCameraComponent;
class UFloatingPawnMovement;
class APlayerCharacter;
class USphereComponent;
class UInventoryComponent;
class UWidgetInteractionComponent;

UCLASS()
class BLOCKADE900_API ACameraPawn : public APawn
{
GENERATED_BODY()

public:
// Sets default values for this pawn's properties
ACameraPawn();

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

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
USphereComponent* CollisionComponent;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
USpringArmComponent* SpringArm;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
UCameraComponent* CameraComponent;
UPROPERTY(VisibleAnywhere,BlueprintReadOnly, Category = "Movement")
UFloatingPawnMovement* FloatingPawnMovement;
**UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Widget interaction")
UWidgetInteractionComponent* WidgetInteraction;**

Begin of CameraPawn.cpp :


#include "CameraPawn.h"
#include "GameFramework/FloatingPawnMovement.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
#include "Components/InputComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Blockade900/Character/PlayerCharacter.h"
#include "Blockade900/Inventory/InventoryComponent.h"
#include "Blockade900/Inventory/Item.h"
#include "Components/BillboardComponent.h"
#include "Components/SphereComponent.h"
**#include "Components/WidgetInteractionComponent.h"**
#include "Kismet/KismetMathLibrary.h"

// Sets default values
ACameraPawn::ACameraPawn()
{
// Don't rotate character to camera direction
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;

// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;

CollisionComponent = CreateDefaultSubobject<USphereComponent>(TEXT("CollisonComponent"));
CollisionComponent->InitSphereRadius(35.0f);
CollisionComponent->SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName);

CollisionComponent->CanCharacterStepUpOn = ECB_No;
CollisionComponent->SetShouldUpdatePhysicsVolume(true);
CollisionComponent->SetCanEverAffectNavigation(false);
CollisionComponent->bDynamicObstacle = true;

RootComponent = CollisionComponent;

//Billboard = CreateDefaultSubobject<UBillboardComponent>(TEXT("Billboard"));

SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
SpringArm->SetupAttachment(RootComponent);
SpringArm->SetUsingAbsoluteRotation(true); // Don't want arm to rotate when player does
SpringArm->TargetArmLength = 1200.f;
SpringArm->SetRelativeRotation(FRotator(-45.f, -90.f, 0.f));
SpringArm->bDoCollisionTest = false; // Don't want to pull camera in when it collides with level

CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
CameraComponent->SetupAttachment(SpringArm, USpringArmComponent::SocketName);
CameraComponent->bUsePawnControlRotation = false;

FloatingPawnMovement = CreateDefaultSubobject<UFloatingPawnMovement>(TEXT("FloatingPawnMovement"));
FloatingPawnMovement->UpdatedComponent = CollisionComponent;

//WidgetInteraction = CreateDefaultSubobject<UWidgetInteractionComponent>(TEXT("WidgetInteraction"));
//WidgetInteraction->SetupAttachment(CameraComponent);

ZoomInterpolationSpeed = 20.f;
ZoomSpeed = 100.f;
MinZoom = 500.f;
MaxZoom = 2200.f;
TargetArm = SpringArm->TargetArmLength;

FollowModeSpeed = 200.f;

Player = nullptr;
SpectatorModeSpeed = 50.f;
bIsSpectatorMode = false;
bMoveCameraMode = false;
}

Also, when I removed UPROPERTY, the code was able to rebuild. However, when I tried to CreateDefaultSubobject, I again got out an error with the next output :


1>------ Rebuild All started: Project: Blockade900, Configuration: Development_Editor x64 ------
1>Cleaning Blockade900Editor and UnrealHeaderTool binaries...
1>Using 'git status' to determine working set for adaptive non-unity build (D:\Unreal Engine\Unreal projects\Blockade900).
1>Creating makefile for Blockade900Editor (no existing makefile)
1>Parsing headers for Blockade900Editor
1> Running UnrealHeaderTool "D:\Unreal Engine\Unreal projects\Blockade900\Blockade900.uproject" "D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\Blockade900Editor\Development\Blockade900Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="C:\Users\Denis\AppData\Local\UnrealBuildTool\Log_UHT.txt" -installed
1>Reflection code generated for Blockade900Editor in 5,6255153 seconds
1>Building Blockade900Editor...
1>Using Visual Studio 2019 14.26.28806 toolchain (D:\Visual Studio\VC\Tools\MSVC\14.26.28801) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Building 56 actions with 8 processes...
1> [1/56] Default.rc2
1> [2/56] Default.rc2
1> [3/56] SharedPCH.Engine.ShadowErrors.cpp
1> [4/56] InteractComponent.cpp
1> [5/56] TemperatureVolumeBox.cpp
1> [6/56] Interactable.cpp
1> [7/56] DissolveObjectsComponent.cpp
1> [8/56] PlayerCharacter.cpp
1> [9/56] AIPlayerCharacterController.cpp
1> [10/56] CameraPawn.cpp
1> [11/56] FoodItem.cpp
1> [12/56] InventoryComponent.cpp
1> [13/56] Item.cpp
1> [14/56] SurvivalSystemComponent.cpp
1> [15/56] InvItemInfo.cpp
1> [16/56] ManPickup.cpp
1> [17/56] DissolveComponent.cpp
1> [18/56] BlockadeGameState.cpp
1> [19/56] InteractableInterface.cpp
1> [20/56] Ladder.cpp
1> [21/56] TemperatureVolumeSphere.cpp
1> [22/56] Module.LoadingScreen.gen.cpp
1> [23/56] TemperatureVolumeSphere.gen.cpp
1> [24/56] FunctionLibrary.cpp
1> [25/56] TemperatureVolumeBase.cpp
1> [26/56] BlockadePlayerController.cpp
1> [27/56] Blockade900.init.gen.cpp
1> [28/56] PlayerMovementComponent.cpp
1> [29/56] BlockadeGameState.gen.cpp
1> [30/56] CameraPawn.gen.cpp
1> [31/56] BlockadePlayerController.gen.cpp
1> [32/56] DissolveComponent.gen.cpp
1> [33/56] DissolveObjectsComponent.gen.cpp
1> [34/56] AIPlayerCharacterController.gen.cpp
1> [35/56] FoodItem.gen.cpp
1> [36/56] Blockade900.cpp
1> [37/56] InteractableInterface.gen.cpp
1> [38/56] Interactable.gen.cpp
1> [39/56] FunctionLibrary.gen.cpp
1> [40/56] InteractComponent.gen.cpp
1> [41/56] InventoryComponent.gen.cpp
1> [42/56] TemperatureVolumeBox.gen.cpp
1> [43/56] PlayerMovementComponent.gen.cpp
1> [44/56] TemperatureVolumeBase.gen.cpp
1> [45/56] ManPickup.gen.cpp
1> [46/56] Ladder.gen.cpp
1> [47/56] SurvivalSystemComponent.gen.cpp
1> [48/56] Item.gen.cpp
1> [49/56] PlayerCharacter.gen.cpp
1> [50/56] InvItemInfo.gen.cpp
1> [51/56] UE4Editor-Blockade900.lib
1> Creating library D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\UE4Editor\Development\Blockade900\UE4Editor-Blockade900.lib and object D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\UE4Editor\Development\Blockade900\UE4Editor-Blockade900.exp
1> [52/56] UE4Editor-Blockade900.dll
1> Creating library D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\UE4Editor\Development\Blockade900\UE4Editor-Blockade900.suppressed.lib and object D:\Unreal Engine\Unreal projects\Blockade900\Intermediate\Build\Win64\UE4Editor\Development\Blockade900\UE4Editor-Blockade900.suppressed.exp
1>CameraPawn.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class UClass * __cdecl UWidgetInteractionComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UWidgetInteractionComponent@@CAPEAVUClass@@XZ) referenced in function "public: __cdecl ACameraPawn::ACameraPawn(void)" (??0ACameraPawn@@QEAA@XZ)
1> Hint on symbols that are defined and could potentially match:
1> "__declspec(dllimport) private: static class UClass * __cdecl AAIController::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@AAIController@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UArrowComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UArrowComponent@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UBillboardComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UBillboardComponent@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UBlueprintFunctionLibrary::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UBlueprintFunctionLibrary@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UBoxComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UBoxComponent@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UCameraComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UCameraComponent@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UDataTable::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UDataTable@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UDecalComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UDecalComponent@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UFloatingPawnMovement::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UFloatingPawnMovement@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UMaterialInstanceDynamic::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UMaterialInstanceDynamic@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UObject::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UObject@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl USphereComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@USphereComponent@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl USpringArmComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@USpringArmComponent@@CAPEAVUClass@@XZ)
1> "__declspec(dllimport) private: static class UClass * __cdecl UStaticMeshComponent::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UStaticMeshComponent@@CAPEAVUClass@@XZ)
1>D:\Unreal Engine\Unreal projects\Blockade900\Binaries\Win64\UE4Editor-Blockade900.dll : fatal error LNK1120: 1 unresolved externals
1> [53/56] Module.LoadingScreen.cpp
1> [54/56] UE4Editor-LoadingScreen.lib
1> Creating library D:\Unreal Engine\Unreal projects\Blockade900\Plugins\LoadingScreen\Intermediate\Build\Win64\UE4Editor\Development\LoadingScreen\UE4Editor-LoadingScreen.lib and object D:\Unreal Engine\Unreal projects\Blockade900\Plugins\LoadingScreen\Intermediate\Build\Win64\UE4Editor\Development\LoadingScreen\UE4Editor-LoadingScreen.exp
1> [55/56] UE4Editor-LoadingScreen.dll
1> Creating library D:\Unreal Engine\Unreal projects\Blockade900\Plugins\LoadingScreen\Intermediate\Build\Win64\UE4Editor\Development\LoadingScreen\UE4Editor-LoadingScreen.suppressed.lib and object D:\Unreal Engine\Unreal projects\Blockade900\Plugins\LoadingScreen\Intermediate\Build\Win64\UE4Editor\Development\LoadingScreen\UE4Editor-LoadingScreen.suppressed.exp
1>D:\Visual Studio\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(54,5): error MSB3073: The command "chcp 65001 >NUL && "D:\Unreal Engine\Versions\UE_4.25\Engine\Build\BatchFiles\Rebuild.bat" Blockade900Editor Win64 Development -Project="D:\Unreal Engine\Unreal projects\Blockade900\Blockade900.uproject" -WaitMutex -FromMsBuild" exited with code -1.
1>Done building project "Blockade900.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

@Denisbaic don’t forget to include in your <ProjectName>.Build.cs:


PublicDependencyModuleNames.AddRange(new string] {** "UMG"**, ... };

References > Module:

https://docs.unrealengine.com/en-US/…ent/index.html

*Thank you for posting your code!

@SolidSk Wow, thanks man, I really forgot about the inclusion of the module in the build.cs file. With the c++, you can not lose concentration :frowning: