Error LNK2019: unresolved external symbol

After adding the FInteriorSettings as a variable to the class, I get an error when compiling.

1>Module.Riders.cpp.obj : error LNK2019: unresolved external symbol "public: __cdecl FInteriorSettings::FInteriorSettings(void)" (??0FInteriorSettings@@QEAA@XZ) referenced in function "public: __cdecl ATestActor::ATestActor(void)" (??0ATestActor@@QEAA@XZ)
1>Riders.generated.2.cpp.obj : error LNK2001: unresolved external symbol "public: __cdecl FInteriorSettings::FInteriorSettings(void)" (??0FInteriorSettings@@QEAA@XZ)

TestActor.h

#pragma once

#include "GameFramework/Actor.h"
#include "Sound/AudioVolume.h"
#include "TestActor.generated.h"

UCLASS()
class RIDERS_API ATestActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ATestActor();

	struct FInteriorSettings InteriorSettings;

	/** The MyProperty */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Game")
	class UBoxComponent* Collision;


	class USceneComponent* Scene;

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

};

TestActor.cpp

#include "Test/TestActor.h"
#include "Riders.h"

// Sets default values
ATestActor::ATestActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;


	Scene = CreateDefaultSubobject<USceneComponent>(TEXT("Scene"));
	Scene = RootComponent;

	Collision = CreateDefaultSubobject<UBoxComponent>(TEXT("Collision"));
	Collision->SetupAttachment(Scene);
}

// Called when the game starts or when spawned
void ATestActor::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void ATestActor::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

}
1 Like

I think you need to add Engine to your project’s Build.cs PublicDependencyModuleNames if it’s not there already.
Also you need to #include "Runtime/Engine/Classes/Sound/AudioVolume.h" in TestActor.h.

You may additionally have problems since InteriorSettings is not a UPROPERTY, so I would recommend marking it as such.

1 Like

All the actions that you described did not work. I get the same error. (

This is strange, because in the file AudioDevice.h
The FListener structure is used, in which this struct FInteriorSettings is described as well as I described it. But I have this error.

#include "Test/TestActor.h"

Is this the same as your TestActor.h file or do you have two headers with the same name?

Yes. This is the same TestActor.h

Your code should work properly adding include .../AudioVolume.h to the top of TestActor.h and replacing struct FInteriorSettings InteriorSettings; with FInteriorSettings InteriorSettings; or at least get different error messages. What error message do you get when you make this change?

Now my TestActor.h looks like this:
#pragma once

#include "GameFramework/Actor.h"
#include "Runtime/Engine/Classes/Sound/AudioVolume.h"
#include "TestActor.generated.h"

UCLASS()
class RIDERS_API ATestActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ATestActor();

	UPROPERTY(EditDefaultsOnly)
	FInteriorSettings InteriorSettings;

	/** The MyProperty */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Game")
	class UBoxComponent* Collision;


	class USceneComponent* Scene;

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

};

But I get the same error.

1>Module.Riders.cpp.obj : error LNK2019: unresolved external symbol "public: __cdecl FInteriorSettings::FInteriorSettings(void)" (??0FInteriorSettings@@QEAA@XZ) referenced in function "public: __cdecl ATestActor::ATestActor(void)" (??0ATestActor@@QEAA@XZ)
1>Riders.generated.2.cpp.obj : error LNK2001: unresolved external symbol "public: __cdecl FInteriorSettings::FInteriorSettings(void)" (??0FInteriorSettings@@QEAA@XZ)

Hmm… I’m very confused why you might still be getting linker errors here. The next things I would try:

  1. Double check, by searching through your module’s code, that you have not declared ATestActor in any other files.

  2. Get rid of the declaration of the constructor in TestActor.h. I believe this constructor is automatically declared in by the GENERATED_BODY macro.

  3. Sometimes things get weird with the Intermediate folder, especially with IDE integration. Remove that whole folder manually and then recreate it by right clicking your uproject and choosing “Generate Project Files”.

I changed the code like this
TestActor.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include “GameFramework/Actor.h”
#include “TestActor.generated.h”

struct FInteriorSettings;

UCLASS()
class RIDERS_API ATestActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ATestActor();

	struct FInteriorSettings InteriorSettings;

	/** The MyProperty */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Game")
	class UBoxComponent* Collision;


	class USceneComponent* Scene;

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

};

I added to the TestActor.h
struct FInteriorSettings;

and in the Test.cpp

FInteriorSettings::FInteriorSettings()
	: bIsWorldSettings(false)
	, ExteriorVolume(1.0f)
	, ExteriorTime(0.5f)
	, ExteriorLPF(MAX_FILTER_FREQUENCY)
	, ExteriorLPFTime(0.5f)
	, InteriorVolume(1.0f)
	, InteriorTime(0.5f)
	, InteriorLPF(MAX_FILTER_FREQUENCY)
	, InteriorLPFTime(0.5f)
{
}

The compilation passed without errors.

Hey, this issue has been caused by someone moving the FInteriorSettings constructor from AudioVolume.h into AudioVolume.cpp.
Could this be moved back please?
It was done in this commit.

[If someone is still looking for a solution]

  1. Update your my_cool_project.build.cs to point out to an external includes folder.
    PublicIncludePaths.Add(“abc:\some_cool_stuff\include”);

  2. Put your some_cool_stuff.lib and some_cool_stuff.dll in the same folder(e.g. bin) and update my_cool_project.build.cs.

    PublicAdditionalLibraries.Add(“abc:\bin\some_cool_stuff.lib”);

1 Like

my problem was similar. I putted “AIModule” into PublicDependencyModuleNames and the compile worked