Hi!
I’m having a problem with plugins that is pretty simple to reproduce, but I don’t know how to solve it.
Error:
CompilerResultsLog: New page: Compilation - Dec 19, 2018, 10:52:18 PM
CompilerResultsLog: Running Mono…
CompilerResultsLog: Found mono via known Mono.framework path
CompilerResultsLog: Running installed mono, version: Mono JIT compiler version 5.16.0.221 (2018-06/b63e5378e38 Mon Nov 19 18:08:09 EST 2018)
CompilerResultsLog: /Users/Shared/Epic Games/UE_4.21/Engine /Users/Shared/Epic Games/UE_4.21/Engine/Binaries/Mac
CompilerResultsLog: Compiling game modules for hot reload
CompilerResultsLog: Performing 2 actions (8 in parallel)
CompilerResultsLog: [1/2] Compile ExampleGameModeBase.cpp
CompilerResultsLog: [2/2] Link UE4Editor-Example-4124.dylib
CompilerResultsLog: Undefined symbols for architecture x86_64:
CompilerResultsLog: “UExampleBlueprintFunctionLibrary::ExampleHelloWord()”, referenced from:
CompilerResultsLog: AExampleGameModeBase::BeginPlay() in ExampleGameModeBase.cpp.o
CompilerResultsLog: ld: symbol(s) not found for architecture x86_64
CompilerResultsLog: clang: error: linker command failed with exit code 1 (use -v to see invocation)
CompilerResultsLog: ERROR: UBT ERROR: Failed to produce item: /Users/Games/Unreal/Example/Binaries/Mac/UE4Editor-Example-4124.dylib
CompilerResultsLog: (see …/Programs/UnrealBuildTool/Log.txt for full exception trace)
CompilerResultsLog: Total build time: 10,17 seconds (Local executor: 0,00 seconds)
How to reproduce the error:
1 - New Project → C++ → Basic Code → “Example” → Create Project
2 - Unreal Editor → Edit → Plugins → New Plugin → Third Party Library | Name: “ExamplePlugin” → Create Plugin
3 - Add New → New C++ Class… → Parent: UBlueprintFunctionLibrary → Next → Name: ExampleBlueprintFunctionLibrary | ExamplePlugin (Runtime) | Public ( Classes doesn’t work either ) → Create Class
4 - In ExampleBlueprintFunctionLibrary.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "ExampleBlueprintFunctionLibrary.generated.h"
/**
*
*/
UCLASS()
class EXAMPLEPLUGIN_API UExampleBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "ExamplePlugin")
static void ExampleHelloWord();
};
5 - In ExampleBlueprintFunctionLibrary.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "ExampleBlueprintFunctionLibrary.h"
static void UExampleBlueprintFunctionLibrary::ExampleHelloWord()
{
UE_LOG(LogTemp, Warning, TEXT("Plugin: Hello world!!"));
}
6 - In Example.Build.cs add:
PublicDependencyModuleNames.Add("ExamplePlugin");
7 - In ExampleGameModeBase.h add:
protected:
virtual void BeginPlay() override;
8 - In ExampleGameModeBase.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "ExampleGameModeBase.h"
#include "ExampleBlueprintFunctionLibrary.h"
void AExampleGameModeBase::BeginPlay()
{
Super::BeginPlay();
UExampleBlueprintFunctionLibrary::ExampleHelloWord();
}
9 - Change World Settings → GameMode: ExampleGameModeBase.
10 - Finally: Compile!
Cause:
This is happening because the cpp file is not being “linked” by the linker.
But I do not know how to solve it. If I change the file ExampleBlueprintFunctionLibrary.h it works:
UFUNCTION(BlueprintCallable, Category = "ExamplePlugin")
static void ExampleHelloWord()
{
UE_LOG(LogTemp, Warning, TEXT("Plugin: Hello world!!"));
}
Sorry for the long post.
Could someone help me understand why the cpp file is not being “linked”?
Thank you very much for your time!