[Bug] Creating C++ class based on DirectionalLight fails to compile

Hi Guys,

Creating a new C++ class via the editor which is based on a DirectionalLight fails with:

CompilerResultsLog:Error: Error MovingSun.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl ADirectionalLight::PostLoad(void)” (?PostLoad@ADirectionalLight@@UEAAXXZ)
CompilerResultsLog:Error: Error XXXXXXXX.generated.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl ADirectionalLight::PostLoad(void)” (?PostLoad@ADirectionalLight@@UEAAXXZ)
CompilerResultsLog:Error: Error MovingSun.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl ADirectionalLight::LoadedFromAnotherClass(class FName const &)” (?LoadedFromAnotherClass@ADirectionalLight@@UEAAXAEBVFName@@@Z)
CompilerResultsLog:Error: Error XXXXXXX.generated.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl ADirectionalLight::LoadedFromAnotherClass(class FName const &)” (?LoadedFromAnotherClass@ADirectionalLight@@UEAAXAEBVFName@@@Z)
CompilerResultsLog:Error: Error MovingSun.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl ADirectionalLight::PostEditChangeProperty(struct FPropertyChangedEvent &)” (?PostEditChangeProperty@ADirectionalLight@@UEAAXAEAUFPropertyChangedEvent@@@Z)
CompilerResultsLog:Error: Error XXXXXXXX.generated.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl ADirectionalLight::PostEditChangeProperty(struct FPropertyChangedEvent &)” (?PostEditChangeProperty@ADirectionalLight@@UEAAXAEAUFPropertyChangedEvent@@@Z)
CompilerResultsLog:Error: Error C:\Users\tommybear\Dropbox\UE4Projects\XXXXXXX\Binaries\Win64\UE4Editor-XXXXXXXX-3358.dll : fatal error LNK1120: 3 unresolved externals

Steps to reproduce:

  • Create new C++ project in 4.11.1
  • Right click in content browser and add a c++ class
  • In the the base class selection window, click “Show all classes”
  • Search for DirectionalLight, select it and click next
  • Name is MovingSun and click create
  • Observe the link error

Tommy.

It’s not bug, ADirectionalLight is flagged with as MinimalAPI which means there is no external linkage from it’s module there for linker can’t link up it to your class.

To improve engine compilation speed, some classes that are less likely to be overrided are marked with MinimalAPI so linker has less work.

The reason why this class was picked for that is most likely because it’s just a shell actor for UDirectionalLightComponent

And if deweloper wants to use directional light he would make new actor with that component insted of overriding that shell actor.

Those shell actors probably was also primarly made for blueprint only users and level designers