错误 LNK2019:使用虚幻引擎项目的 Visual Studio 中无法解析外部符号

问题描述 投票:0回答:1

我只是想在我的 C++ 虚幻引擎项目中创建一个简单的用户小部件,我正在 Visual Studio 中按照这个简短的教程进行操作:https://benui.ca/unreal/ui-cpp-uuserwidget/。这些是文件:

#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "ExampleWidget.generated.h"


// We make the class abstract, as we don't want to create
// instances of this, instead we want to create instances
// of our UMG Blueprint subclass.
UCLASS(Abstract)
class UExampleWidget : public UUserWidget
{
    GENERATED_BODY()

protected:
    // Doing setup in the C++ constructor is not as
    // useful as using NativeConstruct.
    virtual void NativeConstruct() override;
};

#include "ExampleWidget.h"

void UExampleWidget::NativeConstruct()
{
    Super::NativeConstruct();

    // Here is where I typically bind delegates,
    // and set up default appearance
}

我的构建失败了,并给了我

11>ExampleWidget.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl UWidget::FFieldNotificationClassDescriptor::FFieldNotificationClassDescriptor(void)" (__imp_??0FFieldNotificationClassDescriptor@UWidget@@QEAA@XZ) referenced in function "public: virtual struct UE::FieldNotification::IClassDescriptor const & __cdecl UWidget::GetFieldNotificationDescriptor(void)const " (?GetFieldNotificationDescriptor@UWidget@@UEBAAEBUIClassDescriptor@FieldNotification@UE@@XZ)
,不仅仅是一次,而是多次。因此这表明文件链接存在问题。以下是所有错误

11>ExampleWidget.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl UWidget::FFieldNotificationClassDescriptor::FFieldNotificationClassDescriptor(void)" (__imp_??0FFieldNotificationClassDescriptor@UWidget@@QEAA@XZ) referenced in function "public: virtual struct UE::FieldNotification::IClassDescriptor const & __cdecl UWidget::GetFieldNotificationDescriptor(void)const " (?GetFieldNotificationDescriptor@UWidget@@UEBAAEBUIClassDescriptor@FieldNotification@UE@@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl UWidget::FFieldNotificationClassDescriptor::~FFieldNotificationClassDescriptor(void)" (__imp_??1FFieldNotificationClassDescriptor@UWidget@@UEAA@XZ) referenced in function "void __cdecl `public: virtual struct UE::FieldNotification::IClassDescriptor const & __cdecl UWidget::GetFieldNotificationDescriptor(void)const '::`2'::`dynamic atexit destructor for 'Instance''(void)" (??__FInstance@?1??GetFieldNotificationDescriptor@UWidget@@UEBAAEBUIClassDescriptor@FieldNotification@UE@@XZ@YAXXZ)
11>ExampleWidget.gen.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 UClass * __cdecl UUserWidget::StaticClass(void)" (?StaticClass@UUserWidget@@SAPEAVUClass@@XZ)
11>  Hint on symbols that are defined and could potentially match:
11>    "__declspec(dllimport) private: static class UClass * __cdecl UObject::GetPrivateStaticClass(void)" (__imp_?GetPrivateStaticClass@UObject@@CAPEAVUClass@@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl UUserWidget::UUserWidget(class FVTableHelper &)" (__imp_??0UUserWidget@@QEAA@AEAVFVTableHelper@@@Z) referenced in function "class UObject * __cdecl InternalVTableHelperCtorCaller<class UExampleWidget>(class FVTableHelper &)" (??$InternalVTableHelperCtorCaller@VUExampleWidget@@@@YAPEAVUObject@@AEAVFVTableHelper@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl UUserWidget::~UUserWidget(void)" (__imp_??1UUserWidget@@UEAA@XZ) referenced in function "public: virtual __cdecl UExampleWidget::~UExampleWidget(void)" (??1UExampleWidget@@UEAA@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl UUserWidget::UUserWidget(class FObjectInitializer const &)" (__imp_??0UUserWidget@@QEAA@AEBVFObjectInitializer@@@Z) referenced in function "void __cdecl InternalConstructor<class UExampleWidget>(class FObjectInitializer const &)" (??$InternalConstructor@VUExampleWidget@@@@YAXAEBVFObjectInitializer@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UUserWidget(void)" (__imp_?Z_Construct_UClass_UUserWidget@@YAPEAVUClass@@XZ) referenced in function "void __cdecl `dynamic initializer for 'public: static class UObject * (__cdecl*const * const Z_Construct_UClass_UExampleWidget_Statics::DependentSingletons)(void)''(void)" (??__E?DependentSingletons@Z_Construct_UClass_UExampleWidget_Statics@@2QBQ6APEAVUObject@@XZB@@YAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::SetContentForSlot(class FName,class UWidget *)" (?SetContentForSlot@UUserWidget@@UEAAXVFName@@PEAVUWidget@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class UWidget * __cdecl UUserWidget::GetContentForSlot(class FName)const " (?GetContentForSlot@UUserWidget@@UEBAPEAVUWidget@@VFName@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::GetSlotNames(class TArray<class FName,class TSizedDefaultAllocator<32> > &)const " (?GetSlotNames@UUserWidget@@UEBAXAEAV?$TArray@VFName@@V?$TSizedDefaultAllocator@$0CA@@@@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UWidget::BroadcastFieldValueChanged(struct UE::FieldNotification::FFieldId)" (?BroadcastFieldValueChanged@UWidget@@UEAAXUFFieldId@FieldNotification@UE@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl UWidget::RemoveAllFieldValueChangedDelegates(void const *)" (?RemoveAllFieldValueChangedDelegates@UWidget@@UEAAHPEBX@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl UWidget::RemoveAllFieldValueChangedDelegates(struct UE::FieldNotification::FFieldId,void const *)" (?RemoveAllFieldValueChangedDelegates@UWidget@@UEAAHUFFieldId@FieldNotification@UE@@PEBX@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UWidget::RemoveFieldValueChangedDelegate(struct UE::FieldNotification::FFieldId,class FDelegateHandle)" (?RemoveFieldValueChangedDelegate@UWidget@@UEAA_NUFFieldId@FieldNotification@UE@@VFDelegateHandle@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FDelegateHandle __cdecl UWidget::AddFieldValueChangedDelegate(struct UE::FieldNotification::FFieldId,class TDelegate<void __cdecl(class UObject *,struct UE::FieldNotification::FFieldId),struct FNotThreadSafeNotCheckedDelegateUserPolicy>)" (?AddFieldValueChangedDelegate@UWidget@@UEAA?AVFDelegateHandle@@UFFieldId@FieldNotification@UE@@V?$TDelegate@$$A6AXPEAVUObject@@UFFieldId@FieldNotification@UE@@@ZUFNotThreadSafeNotCheckedDelegateUserPolicy@@@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::InitializeInputComponent(void)" (?InitializeInputComponent@UUserWidget@@MEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnMouseCaptureLost(struct FCaptureLostEvent const &)" (?NativeOnMouseCaptureLost@UUserWidget@@MEAAXAEBUFCaptureLostEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FCursorReply __cdecl UUserWidget::NativeOnCursorQuery(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnCursorQuery@UUserWidget@@MEAA?AVFCursorReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnTouchForceChanged(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnTouchForceChanged@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnMotionDetected(struct FGeometry const &,struct FMotionEvent const &)" (?NativeOnMotionDetected@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFMotionEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnTouchEnded(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnTouchEnded@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnTouchMoved(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnTouchMoved@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnTouchStarted(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnTouchStarted@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnTouchGesture(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnTouchGesture@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnDragCancelled(class FDragDropEvent const &,class UDragDropOperation *)" (?NativeOnDragCancelled@UUserWidget@@MEAAXAEBVFDragDropEvent@@PEAVUDragDropOperation@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl UUserWidget::NativeOnDrop(struct FGeometry const &,class FDragDropEvent const &,class UDragDropOperation *)" (?NativeOnDrop@UUserWidget@@MEAA_NAEBUFGeometry@@AEBVFDragDropEvent@@PEAVUDragDropOperation@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl UUserWidget::NativeOnDragOver(struct FGeometry const &,class FDragDropEvent const &,class UDragDropOperation *)" (?NativeOnDragOver@UUserWidget@@MEAA_NAEBUFGeometry@@AEBVFDragDropEvent@@PEAVUDragDropOperation@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnDragLeave(class FDragDropEvent const &,class UDragDropOperation *)" (?NativeOnDragLeave@UUserWidget@@MEAAXAEBVFDragDropEvent@@PEAVUDragDropOperation@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnDragEnter(struct FGeometry const &,class FDragDropEvent const &,class UDragDropOperation *)" (?NativeOnDragEnter@UUserWidget@@MEAAXAEBUFGeometry@@AEBVFDragDropEvent@@PEAVUDragDropOperation@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnDragDetected(struct FGeometry const &,struct FPointerEvent const &,class UDragDropOperation * &)" (?NativeOnDragDetected@UUserWidget@@MEAAXAEBUFGeometry@@AEBUFPointerEvent@@AEAPEAVUDragDropOperation@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnMouseButtonDoubleClick(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnMouseButtonDoubleClick@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnMouseWheel(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnMouseWheel@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnMouseLeave(struct FPointerEvent const &)" (?NativeOnMouseLeave@UUserWidget@@MEAAXAEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnMouseEnter(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnMouseEnter@UUserWidget@@MEAAXAEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnMouseMove(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnMouseMove@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnMouseButtonUp(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnMouseButtonUp@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnPreviewMouseButtonDown(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnPreviewMouseButtonDown@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnMouseButtonDown(struct FGeometry const &,struct FPointerEvent const &)" (?NativeOnMouseButtonDown@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFPointerEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnAnalogValueChanged(struct FGeometry const &,struct FAnalogInputEvent const &)" (?NativeOnAnalogValueChanged@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFAnalogInputEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnKeyUp(struct FGeometry const &,struct FKeyEvent const &)" (?NativeOnKeyUp@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFKeyEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnKeyDown(struct FGeometry const &,struct FKeyEvent const &)" (?NativeOnKeyDown@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFKeyEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnPreviewKeyDown(struct FGeometry const &,struct FKeyEvent const &)" (?NativeOnPreviewKeyDown@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFKeyEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnKeyChar(struct FGeometry const &,struct FCharacterEvent const &)" (?NativeOnKeyChar@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFCharacterEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FNavigationReply __cdecl UUserWidget::NativeOnNavigation(struct FGeometry const &,struct FNavigationEvent const &,class FNavigationReply const &)" (?NativeOnNavigation@UUserWidget@@MEAA?AVFNavigationReply@@AEBUFGeometry@@AEBUFNavigationEvent@@AEBV2@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FNavigationReply __cdecl UUserWidget::NativeOnNavigation(struct FGeometry const &,struct FNavigationEvent const &)" (?NativeOnNavigation@UUserWidget@@MEAA?AVFNavigationReply@@AEBUFGeometry@@AEBUFNavigationEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnRemovedFromFocusPath(struct FFocusEvent const &)" (?NativeOnRemovedFromFocusPath@UUserWidget@@MEAAXAEBUFFocusEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnAddedToFocusPath(struct FFocusEvent const &)" (?NativeOnAddedToFocusPath@UUserWidget@@MEAAXAEBUFFocusEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnFocusChanging(class FWeakWidgetPath const &,class FWidgetPath const &,struct FFocusEvent const &)" (?NativeOnFocusChanging@UUserWidget@@MEAAXAEBVFWeakWidgetPath@@AEBVFWidgetPath@@AEBUFFocusEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnFocusLost(struct FFocusEvent const &)" (?NativeOnFocusLost@UUserWidget@@MEAAXAEBUFFocusEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class FReply __cdecl UUserWidget::NativeOnFocusReceived(struct FGeometry const &,struct FFocusEvent const &)" (?NativeOnFocusReceived@UUserWidget@@MEAA?AVFReply@@AEBUFGeometry@@AEBUFFocusEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl UUserWidget::NativeSupportsKeyboardFocus(void)const " (?NativeSupportsKeyboardFocus@UUserWidget@@MEBA_NXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl UUserWidget::NativeIsInteractable(void)const " (?NativeIsInteractable@UUserWidget@@MEBA_NXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual int __cdecl UUserWidget::NativePaint(class FPaintArgs const &,struct FGeometry const &,class FSlateRect const &,class FSlateWindowElementList &,int,class FWidgetStyle const &,bool)const " (?NativePaint@UUserWidget@@MEBAHAEBVFPaintArgs@@AEBUFGeometry@@AEBVFSlateRect@@AEAVFSlateWindowElementList@@HAEBVFWidgetStyle@@_N@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeTick(struct FGeometry const &,float)" (?NativeTick@UUserWidget@@MEAAXAEBUFGeometry@@M@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeDestruct(void)" (?NativeDestruct@UUserWidget@@MEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativePreConstruct(void)" (?NativePreConstruct@UUserWidget@@MEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::NativeOnInitialized(void)" (?NativeOnInitialized@UUserWidget@@MEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::OnAnimationFinishedPlaying(class UUMGSequencePlayer &)" (?OnAnimationFinishedPlaying@UUserWidget@@MEAAXAEAVUUMGSequencePlayer@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::OnAnimationStartedPlaying(class UUMGSequencePlayer &)" (?OnAnimationStartedPlaying@UUserWidget@@MEAAXAEAVUUMGSequencePlayer@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::OnAnimationFinished_Implementation(class UWidgetAnimation const *)" (?OnAnimationFinished_Implementation@UUserWidget@@MEAAXPEBVUWidgetAnimation@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::OnAnimationStarted_Implementation(class UWidgetAnimation const *)" (?OnAnimationStarted_Implementation@UUserWidget@@MEAAXPEBVUWidgetAnimation@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UUserWidget::Initialize(void)" (?Initialize@UUserWidget@@UEAA_NXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class TSharedPtr<class SWidget,1> __cdecl UWidget::GetAccessibleWidget(void)const " (?GetAccessibleWidget@UWidget@@MEBA?AV?$TSharedPtr@VSWidget@@$00@@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class TSharedRef<class SWidget,1> __cdecl UWidget::RebuildDesignWidget(class TSharedRef<class SWidget,1>)" (?RebuildDesignWidget@UWidget@@MEAA?AV?$TSharedRef@VSWidget@@$00@@V2@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UUserWidget::OnWidgetRebuilt(void)" (?OnWidgetRebuilt@UUserWidget@@MEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class TSharedRef<class SWidget,1> __cdecl UUserWidget::RebuildWidget(void)" (?RebuildWidget@UUserWidget@@MEAA?AV?$TSharedRef@VSWidget@@$00@@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UWidget::OnBindingChanged(class FName const &)" (?OnBindingChanged@UWidget@@MEAAXAEBVFName@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::OnDesignerChanged(struct FDesignerChangedEventArgs const &)" (?OnDesignerChanged@UUserWidget@@UEAAXAEBUFDesignerChangedEventArgs@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FText const __cdecl UUserWidget::GetPaletteCategory(void)" (?GetPaletteCategory@UUserWidget@@UEAA?BVFText@@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FString __cdecl UWidget::GetLabelMetadata(void)const " (?GetLabelMetadata@UWidget@@UEBA?AVFString@@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::SetDesignerFlags(enum EWidgetDesignFlags)" (?SetDesignerFlags@UUserWidget@@UEAAXW4EWidgetDesignFlags@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::SynchronizeProperties(void)" (?SynchronizeProperties@UUserWidget@@UEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class ULocalPlayer * __cdecl UUserWidget::GetOwningLocalPlayer(void)const " (?GetOwningLocalPlayer@UUserWidget@@UEBAPEAVULocalPlayer@@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class APlayerController * __cdecl UUserWidget::GetOwningPlayer(void)const " (?GetOwningPlayer@UUserWidget@@UEBAPEAVAPlayerController@@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UWidget::RemoveFromParent(void)" (?RemoveFromParent@UWidget@@UEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UWidget::IsHovered(void)const " (?IsHovered@UWidget@@UEBA_NXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::SetVisibility(enum ESlateVisibility)" (?SetVisibility@UUserWidget@@UEAAXW4ESlateVisibility@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UWidget::SetIsEnabled(bool)" (?SetIsEnabled@UWidget@@UEAAX_N@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::ReleaseSlateResources(bool)" (?ReleaseSlateResources@UUserWidget@@UEAAX_N@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UUserWidget::IsAsset(void)const " (?IsAsset@UUserWidget@@UEBA_NXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class UWorld * __cdecl UUserWidget::GetWorld(void)const " (?GetWorld@UUserWidget@@UEBAPEAVUWorld@@XZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UVisual::NeedsLoadForServer(void)const " (?NeedsLoadForServer@UVisual@@UEBA_NXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::PostDuplicate(bool)" (?PostDuplicate@UUserWidget@@UEAAX_N@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@UUserWidget@@UEAAXAEAUFPropertyChangedEvent@@@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UWidget::FinishDestroy(void)" (?FinishDestroy@UWidget@@UEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::BeginDestroy(void)" (?BeginDestroy@UUserWidget@@UEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::PostLoad(void)" (?PostLoad@UUserWidget@@UEAAXXZ)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UWidget::Modify(bool)" (?Modify@UWidget@@UEAA_N_N@Z)
11>ExampleWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UUserWidget::PreSave(class FObjectPreSaveContext)" (?PreSave@UUserWidget@@UEAAXVFObjectPreSaveContext@@@Z)
11>ExampleWidget.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) protected: virtual void __cdecl UUserWidget::NativeConstruct(void)" (__imp_?NativeConstruct@UUserWidget@@MEAAXXZ) referenced in function "protected: virtual void __cdecl UExampleWidget::NativeConstruct(void)" (?NativeConstruct@UExampleWidget@@MEAAXXZ)
11>C:\Users\RichardGotherstrom\Documents\Unreal Projects\MyProject\Binaries\Win64\UnrealEditor-MyProject.dll : fatal error LNK1120: 90 unresolved externals
11>
11>Error executing C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\link.exe (tool returned code: 1120)

我一直在寻找如何解决的答案,但并没有真正取得任何进展。虚幻引擎版本为 5.3,在此处的虚幻引擎项目文件中也指定了该版本以及所有插件:

{
    "FileVersion": 3,
    "EngineAssociation": "5.3",
    "Category": "",
    "Description": "",
    "Modules": [
        {
            "Name": "MyProject",
            "Type": "Runtime",
            "LoadingPhase": "Default"
        }
    ],
    "Plugins": [
        {
            "Name": "SunPosition",
            "Enabled": true
        },
        {
            "Name": "DataPrepEditor",
            "Enabled": true
        },
        {
            "Name": "DatasmithImporter",
            "Enabled": true
        },
        {
            "Name": "VariantManager",
            "Enabled": true
        },
        {
            "Name": "PythonScriptPlugin",
            "Enabled": true
        },
        {
            "Name": "HDRIBackdrop",
            "Enabled": true
        },
        {
            "Name": "SequencerScripting",
            "Enabled": true
        },
        {
            "Name": "DatasmithCADImporter",
            "Enabled": true,
            "SupportedTargetPlatforms": [
                "Win64",
                "Linux"
            ]
        },
        {
            "Name": "InterchangeEditor",
            "Enabled": true
        },
        {
            "Name": "AxFImporter",
            "Enabled": true,
            "SupportedTargetPlatforms": [
                "Win64"
            ]
        },
        {
            "Name": "DatasmithRuntime",
            "Enabled": true
        },
        {
            "Name": "OpenXR",
            "Enabled": true,
            "SupportedTargetPlatforms": [
                "Win64",
                "Linux",
                "Android",
                "HoloLens"
            ]
        }
    ]
}

我还尝试将解决方案重新定位到与我的操作系统(Windows 11)兼容的sdk。我还尝试删除根项目文件夹中的文件夹和目录,以通过右键单击虚幻引擎项目文件 -> 显示更多选项 -> 生成 Visual Studio 项目文件来“生成 Visual Studio 项目文件”。如果有帮助的话,我还将分享我通过 Visual Studio 安装程序安装的所有组件 Installed components in visual studio

非常感谢帮助。如果需要更多信息,我会在询问时立即提供。谢谢你。

c++ visual-studio visual-c++ unreal-engine5
1个回答
0
投票

我认为您缺少使用 UMG 模块的依赖项更新

<ProjectName>.Build.cs
的步骤。

来自 https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/ProgrammingWithCPP/CPPTutorials/UMG/

在HowTo_UMG.Build.CS中,我们需要将UMG添加到包含的公共模块列表中,并将Slate和SlateCore添加到包含的私有模块列表中。我们需要修改 HowTo_UMG 构造函数中的第一行,如下所示:

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

然后我们可以取消注释以下行:

PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
© www.soinside.com 2019 - 2024. All rights reserved.