I’m trying to create my first plugin. I’m creating something that uses the Assimp C++ library.
I have my basic plugin created and the library added and it compiles great. I started adding my first Actor class that is going to use the library. When I try to use the std::string in my plugin I get the following errors. Everything compiles until I add the following line in my cpp file. std::string filename = std::string(TCHAR_TO_UTF8(*path));
Running Mono...
Found mono via known Mono.framework path
Running installed mono, version: Mono JIT compiler version 5.16.0.221 (2018-06/b63e5378e38 Mon Nov 19 18:08:09 EST 2018)
/Users/Shared/Epic Games/UE_4.22/Engine /Users/Shared/Epic Games/UE_4.22/Engine/Binaries/Mac
Parsing headers for SixFifteenIOPluginsEditor
Running UnrealHeaderTool "/Users/mwallace/Dropbox/Development/Unreal Projects/SixFifteenIOPlugins/SixFifteenIOPlugins.uproject" "/Users/mwallace/Dropbox/Development/Unreal Projects/SixFifteenIOPlugins/Intermediate/Build/Mac/SixFifteenIOPluginsEditor/Development/SixFifteenIOPluginsEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
Reflection code generated for SixFifteenIOPluginsEditor in 10.2378211 seconds
Performing 4 actions (8 in parallel)
[2/4] Link UE4Editor-SixFifteenIOPlugins-1426.dylib
[1/4] Compile Module.RTAssetLoader.cpp
[3/4] Link UE4Editor-RTAssetLoader-0035.dylib
Undefined symbols for architecture x86_64:
"Assimp::Importer::ReadFile(char const*, unsigned int)", referenced from:
ARTAssetActor::openMesh(FString, int&, FString&) in Module.RTAssetLoader.cpp.o
"Assimp::Importer::Importer()", referenced from:
ARTAssetActor::openMesh(FString, int&, FString&) in Module.RTAssetLoader.cpp.o
"Assimp::Importer::~Importer()", referenced from:
ARTAssetActor::openMesh(FString, int&, FString&) in Module.RTAssetLoader.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is my .h class
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include <string.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "RTAssetActor.generated.h"
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class RTASSETLOADER_API ARTAssetActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ARTAssetActor();
public:
// Called every frame
UFUNCTION(BlueprintCallable, Category = "Assimp")
bool openMesh(FString path, int32 &SectionCount, FString &ErrorCode);
};
Here is my .cpp class
// Fill out your copyright notice in the Description page of Project Settings.
#include "RTAssetActor.h"
#include "assimp/DefaultLogger.hpp"
#include "assimp/Logger.hpp"
// Sets default values
ARTAssetActor::ARTAssetActor()
{
// 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;
}
// Called when the game starts or when spawned
bool ARTAssetActor::openMesh(FString path, int32& SectionCount, FString& ErrorCode)
{
Assimp::Importer importer;
std::string filename = std::string(TCHAR_TO_UTF8(*path));
// std::string filename(TCHAR_TO_UTF8(*path));
const aiScene *scene = importer.ReadFile(filename, aiProcessPreset_TargetRealtime_MaxQuality);
// const aiScene *scene = importer.ReadFile(filename, aiProcessPreset_TargetRealtime_MaxQuality);
// if (!scene)
// {
// ErrorCode = importer.GetErrorString();
// return false;
// }
// _meshCurrentlyProcessed = 0;
// processNode(scene->mRootNode, scene);
// SectionCount = _meshCurrentlyProcessed;
return true;
}