Download

having a frustrating problem with Slate an SlateCore

hello there, i’m trying to make my game’s UI in c++ with Slate and UMG, but i’m having some problems with UserWidget Class.

these are the steps that i took till now:

  1. Added Slate, SlateCore to Private and **UMG **(i also tried without adding UMG) to Public Dependencies in Build.cs.
  2. Checked the **Projects Included Directories **to assure Slate, SlateCore and UMG are in there, which they where.
  3. cleaning the solution and deleting “Binaries” and “Intermediate” Directories in Project Files And **Rebuilding **The Project completely. (i even once rebuilt the Engine itself)
  4. including related header files to the UserWidget file (also tried without including them).
  5. i made a new empty project in unreal and did all of above again (bunch of times!)

after 2 days and lots of frustration i still get this **error **in Visual Studio, (version of UE is **4.25.3 **with visual studio community 2019):


mainMenuWidget.gen.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl UmainMenuWidget::NativeConstruct(void)" (?NativeConstruct@UmainMenuWidget@@MEAAXXZ)

my main purpose was overriding Tick function but as you can’t override tick itself (not virtual) i tried **NativeTick **(also NativeConstruct ect…) and still got the error.

Project.Build.cs:



using UnrealBuildTool;

public class slateUMGuiTest : ModuleRules
{
public slateUMGuiTest(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

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

PrivateDependencyModuleNames.AddRange(new string] { "Slate", "SlateCore" });

}
}


mainMenuWidget.cpp:


#pragma once

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

UCLASS()
class SLATEUMGUITEST_API UmainMenuWidget : public UUserWidget
{
GENERATED_BODY()
protected:
virtual void NativeConstruct() override;
};


can someone please help?

You haven’t implemented the function in a CPP file. If you declare a virtual function then don’t implement it anywhere, you will get link errors.

yeah that solved it, thank you.
such a simple thing and yet visual studio was confusing me with some unclear and confusing error. i went through all the related headers, checked the engine files one by one for two straight days and got more confused because nothing was wrong with them. i don’t know if i can trust my mind anymore.