x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

error LNK2019, I just want to new a Widget in my component

WidgetAroundPawnComponent.h #pragma once

 #include "CoreMinimal.h"
 #include "Components/ActorComponent.h"
 #include "Blueprint/UserWidget.h"
 #include "WidgetAroundPawnComponent.generated.h"
 
 
 UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
 class DARK_API UWidgetAroundPawnComponent : public UActorComponent
 {
     GENERATED_BODY()
 
     //UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
     UUserWidget* Widget;
     
 public:    
     // Sets default values for this component's properties
     UWidgetAroundPawnComponent();
 
 protected:
     // Called when the game starts
     virtual void BeginPlay() override;
 
 public:    
     // Called every frame
     virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
     
 
 };

WidgetAroundPawnComponent.cpp

 #include "WidgetAroundPawnComponent.h"
 
 // Sets default values for this component's properties
 UWidgetAroundPawnComponent::UWidgetAroundPawnComponent()
     :Super()
 {
     PrimaryComponentTick.bCanEverTick = true;
     Widget = NewObject<UUserWidget>(this, UUserWidget::StaticClass());
 }
 
 
 // Called when the game starts
 void UWidgetAroundPawnComponent::BeginPlay()
 {
     Super::BeginPlay();
     
 }
 
 
 // Called every frame
 void UWidgetAroundPawnComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
 {
     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
 
 }

Build log:

 1>------ Build started: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
 2>------ Build started: Project: Dark, Configuration: DebugGame_Editor x64 ------
 2>Parsing headers for DarkEditor
 2>  Running UnrealHeaderTool "C:\Unreal Projects\Dark\Dark\Dark.uproject" "C:\Unreal Projects\Dark\Dark\Intermediate\Build\Win64\DarkEditor\DebugGame\DarkEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
 2>Reflection code generated for DarkEditor in 14.6640206 seconds
 2>Building 4 actions with 4 processes...
 2>  [1/4] WidgetAroundPawnComponent.cpp
 2>  [2/4] WidgetAroundPawnComponent.gen.cpp
 2>  [3/4] UE4Editor-Dark-Win64-DebugGame.lib
 2>     Creating library C:\Unreal Projects\Dark\Dark\Intermediate\Build\Win64\UE4Editor\DebugGame\Dark\UE4Editor-Dark-Win64-DebugGame.lib and object C:\Unreal Projects\Dark\Dark\Intermediate\Build\Win64\UE4Editor\DebugGame\Dark\UE4Editor-Dark-Win64-DebugGame.exp
 2>  [4/4] UE4Editor-Dark-Win64-DebugGame.dll
 2>     Creating library C:\Unreal Projects\Dark\Dark\Intermediate\Build\Win64\UE4Editor\DebugGame\Dark\UE4Editor-Dark-Win64-DebugGame.suppressed.lib and object C:\Unreal Projects\Dark\Dark\Intermediate\Build\Win64\UE4Editor\DebugGame\Dark\UE4Editor-Dark-Win64-DebugGame.suppressed.exp
 2>WidgetAroundPawnComponent.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class UClass * __cdecl UUserWidget::StaticClass(void)" (__imp_?StaticClass@UUserWidget@@SAPEAVUClass@@XZ) referenced in function "class UUserWidget * __cdecl NewObject<class UUserWidget>(class UObject *,class UClass *,class FName,enum EObjectFlags,class UObject *,bool,struct FObjectInstancingGraph *)" (??$NewObject@VUUserWidget@@@@YAPEAVUUserWidget@@PEAVUObject@@PEAVUClass@@VFName@@W4EObjectFlags@@0_NPEAUFObjectInstancingGraph@@@Z)
 2>C:\Unreal Projects\Dark\Dark\Binaries\Win64\UE4Editor-Dark-Win64-DebugGame.dll : fatal error LNK1120: 1 unresolved externals
 2>UnrealBuildTool : error : UBT ERROR: Failed to produce item: C:\Unreal Projects\Dark\Dark\Binaries\Win64\UE4Editor-Dark-Win64-DebugGame.dll
 2>                        (see ../Programs/UnrealBuildTool/Log.txt for full exception trace)
 2>Total build time: 25.07 seconds (Parallel executor: 0.00 seconds)
 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""C:\Program Files\Epic Games\UE_4.20\Engine\Build\BatchFiles\Build.bat" DarkEditor Win64 DebugGame "C:\Unreal Projects\Dark\Dark\Dark.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.
 2>Done building project "Dark.vcxproj" -- FAILED.
 ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I try many way to fix that, but just in vain, I hope someone can help me, thanks!

Product Version: UE 4.20
Tags:
more ▼

asked Mar 07 '19 at 01:09 PM in C++ Programming

avatar image

luckily.lyj
1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Finally kill lnk2019! Add this to your XXX.Build.cs

 PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "RHI", "RenderCore", "ShaderCore", "UMG" });
more ▼

answered Mar 07 '19 at 01:59 PM

avatar image

luckily.lyj
1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question