Custom Log Category generates Error LNK2001

ConnMacros.h (this file has more than this, but it’s mostly useless stuff)

// Copyright William Antonio Pimentel-Tonche. All rights reserved.

#pragma once

#include "CoreMinimal.h"

DECLARE_LOG_CATEGORY_EXTERN(LogConnFramework, Display, Log);

ConnTypes.cpp (this also has more than what is shown)

// Copyright William Antonio Pimentel-Tonche. All rights reserved.

#include "Types/ConnCollection.h"
#include "Types/ConnInput.h"
#include "Types/ConnMacros.h"
#include "Types/ConnRaycast.h"
#include "Types/ConnUtil.h"

#include "Kismet/GameplayStatics.h"
#include "Logging/LogMacros.h"

/**
 * This is a file which contains methods (constructors, functions, operators) for CONNIPTION Framework data types.
 *
 * There are a few advantages to this design:
 * - It's fast. Changes to default values will not require a rebuild of dependent files.
 * - It's more maintanable. Headers can't easily change in patch releases, but source files can.
 * - It's less buggy. Blueprints won't shatter like glass when we update defaults or internal methods.
 *
 * There are disadvantages to take note of, though they are generally minor and well worth the trade:
 * - It's more spread out. We now need to duplicate initializers across multiple constructors or manually call others.
 * - It's very precise. It's possible to mix the initialization order and declaration order.
 * - With all type methods crammed into one file, this one is... pretty long.
 *
 * Format Guide:
 * - Include type headers in alphanumeric order. (EXCEPTION: ConnMacros.h)
 * - Split type headers with this comment format: 

//--------------------------------------------------------------------------------------------------------------------//
// TypeHeaderName.h
//--------------------------------------------------------------------------------------------------------------------//

 * - Constructors should always go before methods.
 */

//--------------------------------------------------------------------------------------------------------------------//
// ConnMacros.h
//--------------------------------------------------------------------------------------------------------------------//

DEFINE_LOG_CATEGORY(LogConnFramework);

When I try to compile this, I get an unresolved external error:

  unresolved external symbol "struct FLogCategoryLogConnFramework LogConnFramework" (?LogConnFramework@@3UFLogCategoryLogConnFramework@@A)

This makes zero sense. I’ve been using this log category all throughout the framework and it decides to stop compiling only just now?

I need this category so that developers using my plugin know exactly where the errors are coming from, so I’d like to get this to work. Thanks, all help is appreciated.

4 Likes

you have to add <MODULE_NAME>_API marco in front of the declaration. see LogTemp declaration in CoreGlobals.h:

CORE_API DECLARE_LOG_CATEGORY_EXTERN(LogTemp, Log, All);

Joe

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.