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

**URL:** <https://forums.unrealengine.com/t/error-lnk2019-i-just-want-to-new-a-widget-in-my-component/444796>\
**Category:** Platform & Builds\
**Tags:** lnk2019, build, unreal-engine, UE4, CPP, question\
**Created:** [March 7, 2019, 1:09pm UTC](https://forums.unrealengine.com/t/error-lnk2019-i-just-want-to-new-a-widget-in-my-component/444796 "2019-03-07T13:09:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![link0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@link0](https://forums.unrealengine.com/u/link0)\
**Post date:** [March 7, 2019, 1:09pm UTC](https://forums.unrealengine.com/t/error-lnk2019-i-just-want-to-new-a-widget-in-my-component/444796/1 "2019-03-07T13:09:20Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![link0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@link0](https://forums.unrealengine.com/u/link0)\
**Post date:** [March 7, 2019, 1:59pm UTC](https://forums.unrealengine.com/t/error-lnk2019-i-just-want-to-new-a-widget-in-my-component/444796/2 "2019-03-07T13:59:03Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![m0ntyx0r](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@m0ntyx0r](https://forums.unrealengine.com/u/m0ntyx0r)\
**Post date:** [August 22, 2022, 5:01am UTC](https://forums.unrealengine.com/t/error-lnk2019-i-just-want-to-new-a-widget-in-my-component/444796/3 "2022-08-22T05:01:18Z")

</div>

Old thread but the same issue. I’ve added “UMG” to my .build and I’m still getting the same error log.
