Compile Error when adding a call to an unparented classes default constructor

Hey I am trying to create an unparented utility class and create a new object of this type in my player controller. I don’t trust the errors I get in visual studio, but I get a "This declaration has no storage class or type specifier on the UCLASS() tag of my controller class. I also get a LINK2019 unresolved external symbol SDSpellsUtil::SDSpellsUtil(void) on the line of code in my controller class where i attempt to invoke the SDSpellsUtil constructor.

I may have spent too long away from c++ and this is just some careless mistake on my end, but I think it’s got something to do with unreal. I’m going to include what I think the relevant pieces of code are but I’m happy to share more.

Utility header file

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "SDBaseSPell.h"
#include "SDDeveloperAngst.h"
#include "SDConstants.h"

/**
 * 
 */
class SOULDRIVE_API SDSpellUtils
{
public:
	SDSpellUtils();
	~SDSpellUtils();

	ASDBaseSpell* LoadSpell(FName SpellName);

private:
	TMap<FName, ASDBaseSpell*> AllSpellsMap;
};

Utility implementation file

// Fill out your copyright notice in the Description page of Project Settings.

#include "SoulDrive.h"
#include "SDSpellUtils.h"

SDSpellUtils::SDSpellUtils()
{
//	AllSpellsMap.Add(SDConstants::DEVELOPER_ANGST, new ASDDeveloperAngst());
}

SDSpellUtils::~SDSpellUtils()
{
}

ASDBaseSpell* SDSpellUtils::LoadSpell(FName SpellName)
{
	if (AllSpellsMap.Contains(SpellName))
	{
		return *AllSpellsMap.Find(SpellName);
	}
	return new ASDBaseSpell();
}

Controller header block, just included so you can double check headers and declaration of utils field.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/PlayerController.h"
#include "Blueprint/UserWidget.h"
#include "SDBaseSpell.h"
#include "SDSpellUtils.h"
#include "SDPlayerController.generated.h"

/**
 * 
 */
UCLASS()
class SOULDRIVE_API ASDPlayerController : public APlayerController
{
	GENERATED_BODY()
	
protected:

	bool bMoveToCursor;

	virtual void PlayerTick(float DeltaTime) override;
	virtual void SetupInputComponent() override;
	void OnSetDestinationPressed();
	void OnSetDestinationReleased();
	void OnDebugActionPressed();
	void OnDebugActionReleased();
	void MoveToCursor();

public:
	ASDPlayerController();
	void BeginPlay() override;

	UFUNCTION(BlueprintCallable, Category = "Input")
	void OverrideHotkey(const FKey Key);

	UFUNCTION(BlueprintCallable, Category = "Input")
	void SetDebugOverride();

	UFUNCTION(BlueprintCallable, Category = "Widgets")
	void OnLaunchPlayerMenu();

	void OnClosePlayerMenu();
	void CastSpellSlot1();
	
	UFUNCTION(BlueprintCallable, Category = "Widgets")
	void SetMenuCanBeOpened(bool NewValue);

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
	TSubclassOf<class UUserWidget> wPlayerGameMenu;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
	uint8 OverwritableAction;

private:

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Player, meta = (AllowPrivateAccess = "true"))
	FString DebugActionAssignedKey;
	
	FName SpellSlot1;
	bool MenuCanBeOpened;
	FInputModeUIOnly KeyRebindInput;
	FInputModeGameAndUI StandardInput;
	UUserWidget* PlayerGameMenu;
	SDSpellUtils* SpellUtils;
};

controller’s beginplay method

void ASDPlayerController::BeginPlay()
{
	Super::BeginPlay();
	SpellUtils = new SDSpellUtils();
	SpellSlot1 = SDConstants::DEVELOPER_ANGST;
	if (wPlayerGameMenu)
	{
		PlayerGameMenu = CreateWidget<UUserWidget>(this, wPlayerGameMenu);
	}
}
  • is that the correct error?

    SDSpellsUtil::SDSpellsUtil(void)

With the Spells instead of Spell?
And Util versus Utils?
And the “void”?

  • You should check the writing of the word Spell(s)Util(s) everywhere.
  • are you sure the .cpp is compiled and linked?

LNK2019 unresolved external symbol “public: __cdecl SDSpellUtils::SDSpellUtils(void)” (??0SDSpellUtils@@QEAA@XZ) referenced in function “public: virtual void __cdecl ASDPlayerController::BeginPlay(void)” (?BeginPlay@ASDPlayerController@@UEAAXXZ) SoulDrive

Sorry, that was just an error on my end typing it into the question. The unresolved external symbol error message does have an exactly matching name.

As for the .cpp being compiled and linked, well, no it’s certainly not that, but that’s precisely my problem.