Using a class from plugin results in "unresolved external symbol"


I’m a bit lost. I use a plugin which implements a class in the public area.

class UTestClass : public UObject


	int32 GiveFoo();


	int32 Foo;

in cpp:

int32 UTestClass::GiveFoo()
	return Foo;

In my project I use the plugin and if I try to use the class I got unresolved external symbol. I am sure I’m missing a library include.

UMyObject::UMyObject(const FObjectInitializer& ObjectInitializer)
	TestClass = NewObject<UTestClass>(this);
	int32 foo = TestClass->GiveFoo();

unresolved external symbol “public: int __cdecl UTestClass::GiveFoo(void)” (?GiveFoo@UTestClass@@QEAAHXZ) referenced in function “private: __cdecl UMyObject::UMyObject(class FObjectInitializer const &)” (??0UMyObject@@AEAA@AEBVFObjectInitializer@@@Z)

What is the best way to get rid of the link error. By adding it to the PublicAdditionalLibraries in the Build.cs. I thought, but so far I have no luck.

Any good hint?


Hmm, maybe try adding the plugin name to the *DependencyModuleNames lists in your Build.cs?

You need to have the XXX_API in your class declaration and get rid of the MinimalAPI specifier, like this:

class XXX_API UTestClass : public UObject

The XXX in XXX_API should be the name of your module. So if your module name is “MyPlugin”, it should be MYPLUGIN_API. If you have the UE4 editor generate a new UObject class from a template for you, it should show you an example of how it should look.

If you don’t do these things, the symbols will not be exported to other modules, so only code in that plugin will be able to use the methods of your class. That’s why you get ‘Unresolved external symbol’ during linking.


Thx man!

The missing XXX_API was the issue and I got a better understanding. Cheers!

No problem! By the way, if you add a comment in AnswerHub, it removes the “answered” flag, and you have to set it again manually. (Sorry to ask you to do that, but I want other people to find it in the future.)

Edit: just realized I probably ended up removing it by replying, haha