Bleakwises slate tutorial produces linker errors ?

i get weird linker errors with the .cpp.obj file from the HUD class:

Error 2 error LNK1120: 1 unresolved externals .

Error 1 error LNK2019: unresolved external symbol “public: void __cdecl SMyWidget::Construct(struct SMyWidget::FArguments const &)” (?Construct@SMyWidget@@QEAAXAEBUFArguments@1@@Z) referenced in function "public: void __cdecl RequiredArgs::T0RequiredArgs::CallConstruct(class TSharedRef const &,struct SMyWidget::FArguments const &)const " (??$CallConstruct@VSMyWidget@@UFArguments@1@@T0RequiredArgs@RequiredArgs@@QEBAXAEBV?$TSharedRef@VSMyWidget@@$0A@@@AEBUFArguments@SMyWidget@@@Z)

so it has something to do with that widget class i figure?

The fact that the error is for your own type rather than a core Slate type suggests that the compiler has seen the declaration for your type, but not the corresponding definition.

Is your cpp file definitely in a place it will be compiled, and does it contain a definition for the Construct function?

SimpleRPGHUD.cpp:

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

#include "SimpleRPG.h"
#include "SimpleRPGHUD.h"
#include "../../Intermediate/ProjectFiles/MyWidget.h"

ASimpleRPGHUD::ASimpleRPGHUD(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	
}

void ASimpleRPGHUD::BeginPlay()
{
	////////////////////////////////////////////////////////////////////////////////////////////////////
	/////Create a SMyUIWidget on heap referenced by MyUIWidget pointer member
	
	
	

	if (!MyWidget.IsValid())
	{
		SAssignNew(MyWidget, SMyWidget)
			.OwnerHUD(this);

		if (MyWidget.IsValid())
		{
			GEngine->GameViewport->AddViewportWidgetContent(
				SNew(SWeakWidget)
				.PossiblyNullContent(MyWidget.ToSharedRef())
				);
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/////Pass our viewport a reference to our widget
	//if (GEngine->IsValidLowLevel())
		//GEngine->GameViewport->
	//	AddViewportWidgetContent( /*reference to widget content*/ SNew(SWeakWidget).PossiblyNullContent(MyWidget.ToSharedRef()));
	/*
	if (MyWidget.IsValid())
	{
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/////Set widget's properties as visibile (sets child widget's properties recurisvely)
		MyWidget->SetVisibility(EVisibility::Visible);
	}
	*/
}


void ASimpleRPGHUD::DrawHUD()
{
	Super::DrawHUD();
}




MyWidget.h:
#pragma once

#include "../../Source/SimpleRPG/SimpleRPGHUD.h"
#include "Slate.h"

class SMyWidget : public SCompoundWidget
{
	public:
	SLATE_BEGIN_ARGS(SMyWidget)
	{}

	SLATE_ARGUMENT(TWeakObjectPtr<ASimpleRPGHUD>, OwnerHUD)

	SLATE_END_ARGS()

	//needed for every widget
	void Construct(const FArguments& InArgs);

	private:
	//Pointer to our parent HUD
	TWeakObjectPtr<class ASimpleRPGHUD> OwnerHUD;
};

MyWidget.cpp:

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
//Author: Bleakwise
//File: MyUIWidget.cpp

#include "../../Source/SimpleRPG/SimpleRPG.h"
#include "MyWidget.h"

void SMyWidget::Construct(const FArguments& InArgs)
{
	OwnerHUD = InArgs._OwnerHUD;
	
	ChildSlot
		.VAlign(VAlign_Fill)
		.HAlign(HAlign_Fill)
		[
			SNew(SOverlay)
			+ SOverlay::Slot()
			.VAlign(VAlign_Top)
			.HAlign(HAlign_Center)
			[
				SNew(STextBlock)
				.ShadowColorAndOpacity(FLinearColor::Black)
				.ColorAndOpacity(FLinearColor::White)
				.ShadowOffset(FIntPoint(-1, 1))
				.Font(FSlateFontInfo("Veranda", 16))
				.Text(FText::FromString("Hello, Slate!"))
			]
		];
	
}

i posted my files above, i do have them in a different directory, as the class wizard would not put them in the same directory where my other project files were but in some /intermediate/ folder. i cannot really tell if a file gets compiled as i dont know how to check that in visual studio, but i noticed that uncommenting the line:

SAssignNew(MyWidget, SMyWidget)
         .OwnerHUD(this);

in SimpleRPGHUD.cpp helps, it compiles then…so it does seem to be connected to the constructor of MyWidget

Okay i solved it by deleting those files in the intermediate folders, and reimplementing it , putting all the widget class files into the source/project folder.

**I guess somehow the linker couldnt take the different directories and messed up the linking process thus.

Thank you very much !!**

that leads me to the next question:is there any way for me to see if the compiler actually sees those files , to circumvent such trouble in the future ?

because apparently i had all the right folders etc in the includes, and still would produce those weird linker errors when invoked in the HUD class.

If instead of posting all the information as separate answers you could post them as comments until you/someone else has found an answer, it would help keep the answers hub more organized and readable for others :slight_smile:

i agree on keeping it organized, but i honestly prefer new posts instead comments , as i do not think comments make it more organized! but ill keep it in my mind for future!

darkZ is correct, these are comments, not answers, and I have moved them to be comments.

The intermediate folder is not somewhere you should place source code, which explains the errors. Glad you’ve got it sorted out.

alright ! yeah i dont know why the class wizard put them into intermediate, but apparently every time you try to create a class with that wizard inside visual studio, it autoplaces it into intermediate, its greyed out from being changed !

Hmm, it seems that it will put them next to the project, which is in the intermediate directory.

That’s a bit annoying, and I don’t think we have any control over it.

You could use the “Add Code to Project…” option in the editor, but I’m not sure how well suited that is to adding new Slate widget classes (it’s really designed for UObject classes).