Why do I get error "inconsistent dll linkage" ?

Hi, I want to call a funciton from a plugin but I get this error “inconsistent dll linkage”.
This is the header file

#pragma once

#include "CoreMinimal.h"
#include "../../Plugins/FliteTTSPlugin/Source/FliteTTSPlugin/Public/IFliteTTSPlugin.h"
#include "../../Plugins/FliteTTSPlugin/Source/FliteTTSPlugin/Public/FliteTTSPlugin.h"

#include "lex_test.generated.h"




/**
 * 
 */
 UCLASS()
class FLITETTSPLUGIN_API Alex_test : public AActor, public IFliteTTSPlugin
{
	//virtual void StartupModule() override; 
	//virtual void ShutdownModule() override; 
	
	GENERATED_UCLASS_BODY() 
	
	
public:
	Alex_test();
	~Alex_test();
	
	 UFUNCTION(BlueprintCallable, Category = "citeste")
	 void citeste(FString str);
	 
}; 

This is the source file

// Fill out your copyright notice in the Description page of Project Settings.
#include "MyProject.h"
#include "lex_test.h"

Alex_test::Alex_test()
{

}

Alex_test::~Alex_test()
{
}

void Alex_test::citeste(FString str)
{
	
	UE_LOG(LogTemp, Warning, TEXT("%s"), *str);
	
IFliteTTSPlugin::writefile();
	
}

The function I want to call is in FliteTTSPlugin file.
Do you know how to do this? Thankyou.

1 Like

you need to edit your Build.cs and add “FliteTTSPlugin” to your public dependency: PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "FliteTTSPlugin" });
Check the proper name of the plugin Then Rebuild your project and it should be available using only #inlcude "IFliteTTSPlugin.h" and #include "FliteTTSPlugin.h"

I forgot to mention this, I already edited the build.cs with “PrivateDependencyModuleNames.AddRange(new string[] { “FliteTTSPlugin” });
PrivateIncludePathModuleNames.AddRange(new string[] { “FliteTTSPlugin” });”, should be public ? Problem is class FLITETTSPLUGIN_API, if I delete this I get unresolved symbol.

I wrote as you said, same problem

I updated it, problem is not with the plugin files. The function I am trying to call is not from the plugin itself though I would like to. In FliteTTSPlugin.h I defined function writefile() which just make an UELOG for testing purposes and I want to call that function. If this will work, I will write some plugin functions in writefile().

I found this "If you look at the plugin tutorials you’ll notice that IModule only has inline and pure virtual methods, and its parent class IModuleInterface likewise only contains inline methods, there’s no need to export anything in order to use either of those classes in your project because all the relevant information is already in the header files. The same thing applies to UE modules that don’t use MODULE_API. In your case however, your FTestModule has a Test method that isn’t inline, nor pure virtual, which means that when you link your project against your module the linker is going to try and find the definition of that method in your module’s library. You can read more about the different ways to export classes from DLLs in this article. " in link text

the thing is that this plugin was not updated in 2 years and it was incomplete at the time. You might not be able to make it work at all at least according the the readme of the plugin.

This was so easy, so I made these changes
UCLASS(MinimalAPI) class Alex_test : public AActor ... FFliteTTSPlugin* flite;

and I called it like this flite->writefile();

Just to mention, got the error after adding a new c++ class to my existing sources and forgot by pasting in the code from an other project to fix the “YOURMODULENAME_API” - which caused the same error messages :slight_smile:

2 Likes

This was the solution to my problem whilst looking this up. Thank you!

I had this driving me crazy in 5.1. Turns out I accidentally left a copy pasted

#include UE_INLINE_GENERATED_CPP_BY_NAME()

In a .cpp file for a class that I was extending from the original class. I forgot to delete that line when I copied code from the original file.

1 Like

Faced the same incessant error, and my issue was that I had copied code from the engine to use as a base for a custom implementation but did not change the struct from ENGINE_API to my own one.

2 Likes