error LNK 1120 and LNK 2019 and being stuck

I did a lot of googling about LNK1120 and LNK 2019. Yet I cannot grasp what is the problem.

I am still stuck at this error message.

CompilerResultsLog: Error: NCFT_PlayerController.cpp.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: class ABase_Character * __cdecl UCharacterManager::GetTheCharacterByIndex(int,enum EUnitTypeEnum)” (_imp?GetTheCharacterByIndex@UCharacterManager@@QEAAPEAVABase_Character@@HW4EUnitTypeEnum@@@Z) referenced in function “public:
void __cdecl ANCFT_PlayerController::GetThePlayerCharacter(void)” (?GetThePlayerCharacter@ANCFT_PlayerController@@QEAAXXZ)

I checked whether I missed Classname:: and constructors. but i am pretty sure it is solid.

Sign… I have short time and it bugs me pretty bad.

here goes codes.

NCFT_GameController.h



#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "EnumHeader.h"
#include "Base_Character.h"
#include "NCFT_PlayerController.generated.h"

UCLASS()
class NOCOUNTRYFORTHEM415_API ANCFT_PlayerController : public APlayerController
{
public:
    ANCFT_PlayerController(const FObjectInitializer& ObjectInitializer);
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Controll a player Unit")
        class ABase_Character* theControllableCharacter;
UFUNCTION(BlueprintCallable, Category = "Controll a player Unit")
        void GetThePlayerCharacter();
//and the rest of code goes...
}






#include "NoCountryForThem415.h"
#include "NCFTGameInstance.h"
#include "NCFT_PlayerController.h"


ANCFT_PlayerController::ANCFT_PlayerController(const FObjectInitializer& ObjectInitializer)
    :Super(ObjectInitializer)
{
   theControllableCharacter = NULL;
}

void ANCFT_PlayerController::GetThePlayerCharacter()
{
    UNCFTGameInstance* instance = Cast<UNCFTGameInstance>(UGameplayStatics::GetGameInstance(this));
    if (instance)
    {
        if (theControllableCharacter == NULL)
        {
            //the  code that cause the problem.
            theControllableCharacter =instance->CharactersManager->GetTheCharacterByIndex(0, EUnitTypeEnum::UTE_PLAYER);

        }
    }
}



CharacterManager.h



#pragma once
#include "NoCountryForThem415/Public/EnumHeader.h"
#include "UObject/NoExportTypes.h"
#include "Base_Character.h"
#include "Character_Stat.h"
#include "CharacterManager.generated.h"
//it is in Different API Module, but The Game Instance has it as SubOject.
UCLASS(Blueprintable, BlueprintType)
class NCFT_CHARACTERS_API UCharacterManager : public UObject
{
GENERATED_BODY()
public:
    UCharacterManager(const FObjectInitializer& ObjectInitializer);
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Current PlayerUnits Party")
        TArray<class ABase_Character*> PlayerUnits;
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Current EnemyUnits Party")
        TArray<class ABase_Character*> EnemyUnits;
    //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Current EnemyUnits Party")
    //    int m_iCreatedEnemyIndex;
    UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Datas in Battle") 
        class ABase_Character* GetTheCharacterByIndex(int index, EUnitTypeEnum _type);
}


CharacterManager.cpp




#include "NCFT_Characters.h"
#include "CharacterManager.h"


UCharacterManager::UCharacterManager(const FObjectInitializer& ObjectInitializer)
    :Super(ObjectInitializer)
{

}

class ABase_Character* UCharacterManager::GetTheCharacterByIndex(int index, EUnitTypeEnum _type) 
{

    switch (_type)
    {
    case EUnitTypeEnum::UTE_PLAYER:
    {
        if (PlayerUnits.Num() <= index) return NULL;
        return PlayerUnits[index];
    }
    case EUnitTypeEnum::UTE_ENEMY:
    {
        if (EnemyUnits.Num() <= index) return NULL;
        return EnemyUnits[index];
    }
    default:
    {
        break;
    }
    }
    return NULL;

}


and lastly my project build.cs




using UnrealBuildTool;

public class NoCountryForThem415 : ModuleRules
{
    public NoCountryForThem415(TargetInfo Target)
    {
        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "Paper2D", "UMG", "Slate", "SlateCore", "RHI", "RenderCore", "ShaderCore", "NCFT_Battles", "NCFT_Characters" });

        //PrivateDependencyModuleNames.AddRange(new string] {  });

        // Uncomment if you are using Slate UI
        PrivateDependencyModuleNames.AddRange(new string] { "Slate", "SlateCore" });

        // Uncomment if you are using online features
        // PrivateDependencyModuleNames.Add("OnlineSubsystem");

        // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
    }
}



Sign… somebody help me… :frowning:

Now I have another issue that… my Unreal Engine Editor won’t start with this message.

Assertion failed: GIsHotReload [File:D:\Build++UE4+Release-4.17+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp] [Line: 608] Trying to recreate class ‘UEnumHeader’ outside of hot reload!

I remember that I had to delete Intermediate Folder and Binary Folder to regenerate the whole project again. Do I actually do that again? I am too stressed…

fixed that message error, back to LNK 1120 and LNK 2019 problem… sign… i need rest for now

Your ANCFT_PlayerController is missing GENERATED_BODY(), not sure if that’s related to this issue.

oops i forgot to copy that to above code. thanks. but in my actual code has GENERATED_BODY().

anyway thank you!

I put own modules from some Korean dev’s lecture in Korean Unreal Naver Community.

Few things i did for my own module.

  1. I added the module in PublicModuleDependencyNames. (I also tried in PrivateModuleDependencyNames as well, it does not change about the error.
    2.I also put the module name in Build.cs and .uproject.
  2. I also put the module name in Target and TargetEditor files.

is there anything that i missed?

There’s no obvious error I can see that would generate those linker errors, however you have a dependency on NCFT_Characters from NoCountryForThem415, but at the same time in CharacterManager.h you are including EnumHeader from the NoCountryForThem415 module.

Normally just inclusion of a header and use of an enum type would not cause issues, but in this case your header contains reflected types and you’re using them in reflected functions; it wouldn’t surprise me if this is somehow leading to the linker error. Either way having that include back to your NoCountryForThem415 module is bad design. I suggest you rearrange your code so that if the enum is needed by the characters module, then it is declared in the characters module, or some module used by both the characters modules and the game module.

Thank you sir. I am still sloppy in modules and still am beginner. I appreciate your concern about… dependency. Yeah, I can see my silliness (not sure that’s correct term)… phew I feel better. You sir, saved my stupid existence. Cheers!

My Character module is working with depending (simply put, its Build.cs “PublicDependencyModuleName”)a separate module (I called it Enums) and it worked fine.

Now I face more strange and unrecognizable problem (maybe because my programming is still lacking -_-;).

1.I created another module named “Events” and also depending (is it right?) Enums Module like my previous module did.

But it causes same errors (scary LNK2019 and LNK 1120 errors!)

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol “__declspec(dllimport) class UEnum * __cdecl Z_Construct_UEnum_NCFT_Enums_EEventZoneTypeEnum(void)” (_imp?Z_Construct_UEnum_NCFT_Enums_EEventZoneTypeEnum@@YAPEAVUEnum@@XZ) referenced in function “class UClass * __cdecl Z_Construct_UClass_AEventZone(void)” (?Z_Construct_UClass_AEventZone@@YAPEAVUClass@@XZ) NoCountryForThem417 D:\NoCountryForThem\Programming\Unreal\NoCountryForThem417\NoCountryForThem417\Intermediate\ProjectFiles\EventZone.gen.cpp.obj 1

most strange thing is… if I don’t use the certain code which related Enums, it builds just fine.

I seemed to find the problem and tried other Enum just in case, but that other Enum is working fine.

Thus that specific Enum is causing problem…

here goes code

EnumHeader.h



UENUM(BlueprintType)
enum class EEventZoneTypeEnum : uint8
{
    ETZE_BATTLE UMETA(DisplayName = "Battle"),
    ETZE_FORBIDDEN UMETA(DisplayName = "Forbidden"),
    ETZE_CHOICES UMETA(DisplayName = "Choices"),
    ETZE_STORY UMETA(DisplayName = "Story")
};


UCLASS()
class NCFT_ENUMS_API UNCFT_EnumHeader : public UObject
{
    GENERATED_UCLASS_BODY()

public:
    //EventZoneType
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EventZoneTypeEnum")
        EEventZoneTypeEnum EventZoneTypeEnum;
//and other code goes.
}



EventZone.h




#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "NCFT_EnumHeader.h"
#include "EventZone.generated.h"


UCLASS()
class NCFT_EVENTS_API AEventZone : public AActor
{
    GENERATED_BODY()

public:    
    // Sets default values for this actor's properties
    AEventZone(const FObjectInitializer& ObjectInitializer);
    UPROPERTY(VisibleAnywhere, Category = "Collision Box")
        class UBoxComponent* CollisionBox;
//the certain enum causing the error
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Event Type")
        EEventZoneTypeEnum EventType;
//but this enum is working
//    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Direction")
//        ECharacterDirectionEnum m_i8CharDirection;

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public:    
    // Called every frame
    virtual void Tick(float DeltaTime) override;
    void OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
    //
};


EventZone.cpp




#include "NCFT_Events.h"
#include "EventZone.h"


// Sets default values
AEventZone::AEventZone(const FObjectInitializer& ObjectInitializer)
    :Super(ObjectInitializer)
{
     // 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;
    CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionBox"));
    RootComponent = CollisionBox;
    CollisionBox->bGenerateOverlapEvents = true;
    CollisionBox->OnComponentBeginOverlap.AddDynamic(this, &AEventZone::OnOverlapBegin);
    //default
    EventType = EEventZoneTypeEnum::ETZE_STORY;
}

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

}

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


}

void AEventZone::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
    //other actor is the actor that triggered the event. Check that is not ourself.
    if ((OtherActor != nullptr) && (OtherActor != this) && (OtherComp != nullptr))
    {
        //is that player unit?
        /*
        if (OtherActor->ActorHasTag("Player"))
        {
            //if it is player unit    show text or trigger the event.

        }
        */
    }
}



  1. this is much worse. 1st problem… I could just get rid of the certain code for a moment (but i need that code!). After build finishes without that code, I open Unreal Engine Editor, it crashes

LoginId:37a6db4b44f4691c67253e98831af189
EpicAccountId:

Access violation - code c0000005 (first/second chance not available)

UE4Editor_CoreUObject!UObjectBaseUtility::GetFullName() [d:\build++ue4+release-4.17+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectbaseutility.cpp:81]
UE4Editor_CoreUObject!FRealtimeGC::MarkObjectsAsUnreachable() [d:\build++ue4+release-4.17+compile\sync\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:733]
UE4Editor_CoreUObject!FRealtimeGC::PerformReachabilityAnalysis() [d:\build++ue4+release-4.17+compile\sync\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:858]
UE4Editor_CoreUObject!CollectGarbageInternal() [d:\build++ue4+release-4.17+compile\sync\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:1413]
UE4Editor_CoreUObject!CollectGarbage() [d:\build++ue4+release-4.17+compile\sync\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:1533]
UE4Editor_UnrealEd!UEditorEngine::Map_Load() [d:\build++ue4+release-4.17+compile\sync\engine\source\editor\unrealed\private\editorserver.cpp:2703]
UE4Editor_UnrealEd!UEditorEngine::HandleMapCommand() [d:\build++ue4+release-4.17+compile\sync\engine\source\editor\unrealed\private\editorserver.cpp:5991]
UE4Editor_UnrealEd!UEditorEngine::Exec() [d:\build++ue4+release-4.17+compile\sync\engine\source\editor\unrealed\private\editorserver.cpp:5468]
UE4Editor_UnrealEd!UUnrealEdEngine::Exec() [d:\build++ue4+release-4.17+compile\sync\engine\source\editor\unrealed\private\unrealedsrv.cpp:672]
UE4Editor_UnrealEd!FEditorFileUtils::LoadMap() [d:\build++ue4+release-4.17+compile\sync\engine\source\editor\unrealed\private\filehelpers.cpp:2192]
UE4Editor_UnrealEd!FEditorFileUtils::LoadDefaultMapAtStartup() [d:\build++ue4+release-4.17+compile\sync\engine\source\editor\unrealed\private\filehelpers.cpp:3509]
UE4Editor_UnrealEd!FUnrealEdMisc::OnInit() [d:\build++ue4+release-4.17+compile\sync\engine\source\editor\unrealed\private\unrealedmisc.cpp:348]
UE4Editor_UnrealEd!EditorInit() [d:\build++ue4+release-4.17+compile\sync\engine\source\editor\unrealed\private\unrealedglobals.cpp:97]
UE4Editor!GuardedMain() [d:\build++ue4+release-4.17+compile\sync\engine\source\runtime\launch\private\launch.cpp:150]
UE4Editor!GuardedMainWrapper() [d:\build++ue4+release-4.17+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:134]
UE4Editor!WinMain() [d:\build++ue4+release-4.17+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:210]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253]
kernel32
ntdll

When a crash happens, mostly I messed up For Loop. but… this time I am pretty clueless.

Only thing I did were

  • Imported .csv file
  • Created struct which gets data from .csv file.
  • Few more class which involving with Events Modules.

I need to some time to chill. My mentality might get worse.

okay… i got the 2nd problem. that struct was causing the problem.

I guess i need to sort them out… but i need rest or sleep… I am feeling strange.

edit. after i did massive changes in codes, it starts working again… FacePalm