Download

DebugEditor compiles but other builds sometimes don't.

Right now DebugGame fails to compile due to a linker error, but DebugEditor compiles no problem:



1>AGEquippableMagazineLoadStateMachineInstance.cpp.obj : error LNK2001: unresolved external symbol "struct FGameplayTag const SFLD__EQUIPPABLE__STATE__BEHAVIOR__BLOCK_UNEQUIP__TAG" (?SFLD__EQUIPPABLE__STATE__BEHAVIOR__BLOCK_UNEQUIP__TAG@@3UFGameplayTag@@B)
1>C:\Code\UnrealEngineProj\AnomalyGate\Binaries\Win64\UE4Editor-AnomalyGate-Win64-DebugGame.dll : fatal error LNK1120: 1 unresolved externals


We have a constant declared in a header:



#pragma once

#include "GameplayTagAssetInterface.h"

extern const FGameplayTag SFLD__EQUIPPABLE__STATE__BEHAVIOR__BLOCK_UNEQUIP__TAG;


And defined in a cpp file:



#include "SFLDGameplayTags.h"

const FGameplayTag SFLD__EQUIPPABLE__STATE__BEHAVIOR__BLOCK_UNEQUIP__TAG = FGameplayTag::RequestGameplayTag("SFLD.Equippable.State.Behavior.BlockUnequip");


What could be causing one build configuration to compile and another not to? This happens on multiple people’s machines in 4.24.3. When compiled from source it happens too. We tried cleaning as well.

It would seem that it’s failing to find your CPP (or it’s somehow failing to compile). Is RequestGameplayTag an Editor only method? Are GameplayAbilities somehow not being marked a dependency in your client build?

It’s definitely a config issue, so I’d compare your Project vs ProjectEditor .build.cs files.

I haven’t found evidence of it being editor only. GameplayTags is actually in its own library separate from abilities. I can double check to make sure all the libs are being added as dependencies.



/**
 * A single gameplay tag, which represents a hierarchical name of the form x.y that is registered in the GameplayTagsManager
 * You can filter the gameplay tags displayed in the editor using, meta = (Categories = "Tag1.Tag2.Tag3"))
 */
USTRUCT(BlueprintType, meta = (HasNativeMake = "GameplayTags.BlueprintGameplayTagLibrary.MakeLiteralGameplayTag", HasNativeBreak = "GameplayTags.BlueprintGameplayTagLibrary.GetTagName"))
struct GAMEPLAYTAGS_API FGameplayTag
{
    GENERATED_USTRUCT_BODY()

    /** Constructors */
    FGameplayTag()
    {
    }

    /**
     * Gets the FGameplayTag that corresponds to the TagName
     *
     * @param TagName The Name of the tag to search for
     * @param ErrorIfNotfound: ensure() that tag exists.
     * @return Will return the corresponding FGameplayTag or an empty one if not found.
     */
    static FGameplayTag RequestGameplayTag(FName TagName, bool ErrorIfNotFound=true);


I just updated every bit of my project to the latest build settings with IWYU all set up. And I still have the same problem.

DefaultBuildSettings = BuildSettingsVersion.Latest;

Tried with Unity on and Off.

Everything compiles great before the linker step but I still get that linker error only on DebugGame but not in DebugEditor.

OK!

Figured it out. I was missing the DLL Export macro on my constants in the header. They were declared in a different module. Still not sure why DebugEditorCompiled. I usually find myself failing to compile even Debug Editor builds if I forget this.

Be sure to include that macro in front:


MODULENAMEGOESHERE_API extern const ....