Plugins can not use another plugins?

I’m working on an editor module plugin where I want use another plugin’s static methods.
I added the #include “MySQLBPLibrary.h” which provides me access to its methods.
Source compiles, intellisense shows its methods, but build failed due to linker error.
I added the depedency to my plugin’s build.cs to PublicDependencyModuleNames section.
The plugin I want to use is a paid plugin from Marketplace (MySQL connector). I see all required files (lib, dll) in the installed engine marketplace plugin source folder, but seems the linker cannot find it.
In case if I want use the plugin from normal UE4 project, even C++, it builds fine, only usage in another plugin seems problematic. Because of it works with normal projects, I think its an UE4 problem.
Have you any idea what I need to add/update to link properly? (as I dont think I need manually add engine marketplace plugin path to build.cs, buildtool should use default, shouldnt?

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2019	unresolved external symbol "public: static void __cdecl UMySQLBPLibrary::SetConnectionProperties(class FString,class FString,class FString,class FString,class FString,bool)" (?SetConnectionProperties@UMySQLBPLibrary@@SAXVFString@@0000_N@Z) referenced in function "public: virtual void __cdecl MyPlugin::StartupModule(void)" (?StartupModule@MyPlugin@@UEAAXXZ)	KalibratorPlugin	d:\Unreal Projects\KalibratorPlugin\Intermediate\ProjectFiles\MyPlugin.cpp.obj	1

SQL plugin is not mone, its from marketplace. I want use it in an another plugin I written. I think its properly exported b/c it works fine with BP and C++ normal UE4 projects.

Is this method properly exported from your SQL plugin? I can verify that there is no inherent problem with a plugin dependent on another plugin, I’ve used it successfully.

If I remember correctly, the newer versions of the engine also allow you to specify dependent plugins in your own .UPLUGIN file so that the loading order is automatically resolved correctly.

First, you have to make sure the module of the other plugin is already loaded before you use it.
PluginB.uplugin must be set to load before your MyPlugin.uplugin does. Your MyPlugin.uplugin should have a statement like this:

“Modules”: [ { “Name”: “MyPluginName”, “Type”: “Runtime”, “LoadingPhase”: “Default” }]

and PluginB have to be set to:

“Modules”: [ { “Name”: “PluginBName”, “Type”: “Runtime”, “LoadingPhase”: “PreDefault” }]

That ensures that PluginB will always be already loaded before your own plugin executes any code.
_
To see if that module has been loaded before you execute code in your own plugin, you can use:

IPluginB::Get()

or

FModuleManager::LoadModuleChecked<FPluginBModule>("PluginBName").Get();

_
Second, you can’t use any functions from another Module that aren’t exported.

PluginB should declare classes and/or functions with an export macro that allows external code to use them;

Plugins are just custom Modules you attach to the engine code.

So check PluginB’s header files and make sure the classes you want to use have a PLUGINNAME_API macro attached to the UCLASS declaration, if that’s not the case then that’s why you get unresolved external symbol error.

1 Like

Oh yes, I forgot about this; It’s very very recent additional mechanism tho.

	"Modules": [
		{
			"Name": "MyPlugin",
			"Type": "Runtime",
			"LoadingPhase": "Default",
			"WhitelistPlatforms": [
			  "Win64",
			  "Win32",
			  "Linux",
			  "Mac",
			  "iOS",
			  "Android"
			]
		},
		{
			"Name": "MyPluginEditor",
			"Type": "Editor",
			"LoadingPhase": "PostEngineInit",
			"WhitelistPlatforms": [
			  "Win64",
			  "Linux",
			  "Mac"
			]
		}
	],
	"Plugins": [
		{
			"Name": "MySQL",
			"Enabled": true
		}
	]

Unfortunately setting LoadingPhase didnt help in uplugin file. The author of plugin I want use told me he exported the methods.
I found the method in MySQLBPLibrary.h:

UFUNCTION(BlueprintCallable, Category = “MySql Server”)
static void SetConnectionProperties(FString Server, FString DBName, FString UserID, FString Password,
FString ExtraParam , bool IsTrusted);

so its a BP function.
calling it works in a normal UE4 C++ project, using in plugins have a difference…?

I made an experiment, copied plugin source from engine marketplace plugins folder to my project and added the API macro you recommended to uclass() and it works! Thanks