How linking work in UE build

I happen to have a situation where there’s 3 Public and Private DependencyModuleNames with comment stating which PublicDependencyModuleNames is for the game, plugin etc
In .build.cs

PublicDependencyModuleNames.AddRange(new string { SlateCore});
PublicDependencyModuleNames.AddRange(new string { });
PublicDependencyModuleNames.AddRange(new string { });
PrivateDependencyModuleNames.AddRange(new string {Slate });
PrivateDependencyModuleNames.AddRange(new string { });
PrivateDependencyModuleNames.AddRange(new string { });
and each has different modules for different parts of the project

and I have

error LNK2019: unresolved external symbol “__declspec(dllimport) public: static class ISlateStyle const & __cdecl ::Get(void)” (_imp?Get@@@SAAEBVISlateStyle@@anonymous_user_9674a66c) referenced in function “public: virtual void __cdecl MyClass::CustomizeDetails(class IDetailLayoutBuilder &)” (?CustomizeDetails@MyClass@@UEAAXAEAVIDetailLayoutBuilder@@@Z)

I also tried to have both of them in public and in private but it didnt work

so how does unreal engine knows that the second one should be for the plugin and the third one for the game

I am open to someone correcting me if I’m wrong, but basically you’re always building the project.
A plugin is just dependency code for the project being built
So ultimately, UE build doesn’t care, it just gathers all the modules it needs to load (which it find by reading all the included build.cs files) and compiles them.
A module is the same whether it’s stated in the plugin build or the project build, so it will be included either way

1 Like

so you are saying that it will combine all PublicDependencyModuleNames and link it to the project?

As per @jojothebandit , it’s like an array, and it doesn’t matter how many lines you use to add modules. They all will end up in one array.

As for the second part of your question, you’re adding strings, so they should be “SlateCore” and “Slate”, i.e. in double quotes.

1 Like

Thanks, so it’s just style to have clean code
and yes they are strings, this is just a mock up

This in most cases means you have the declaration(the .h file) but not the definition (the .cpp file) so check out why the module is included and not linked.
This can happen if the module does not allow you to use it (it didn’t expose the method) or it’s a private module or something similar

I doubt this is the case because my code works without my custom slate UI