Inheriting UDirectionalLightComponent

UPDATE: Problem has been fixed.

I’m getting linker errors when I inherit UDirectionalLightComponent.

Likely it’s because I need to add a module dependency to my Build.cs, but I don’t know which one.
Anyone know?

Also, where can I find a list of modules to prevent future issues?

Thanks guys!



#pragma once

#include "Components/DirectionalLightComponent.h"
#include "VDirectionalLightComponent.generated.h"

/**
 * 
 */
UCLASS()
class VIOLETS_API UVDirectionalLightComponent : public UDirectionalLightComponent
{
	GENERATED_BODY()
	
	
	
	
};


Generates the following on build:



18>VDirectionalLightComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FVector4 __cdecl UDirectionalLightComponent::GetLightPosition(void)const " (?GetLightPosition@UDirectionalLightComponent@@UEBA?AUFVector4@@XZ)
18>Violets.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FVector4 __cdecl UDirectionalLightComponent::GetLightPosition(void)const " (?GetLightPosition@UDirectionalLightComponent@@UEBA?AUFVector4@@XZ)
18>VDirectionalLightComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual enum ELightComponentType __cdecl UDirectionalLightComponent::GetLightType(void)const " (?GetLightType@UDirectionalLightComponent@@UEBA?AW4ELightComponentType@@XZ)
18>Violets.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual enum ELightComponentType __cdecl UDirectionalLightComponent::GetLightType(void)const " (?GetLightType@UDirectionalLightComponent@@UEBA?AW4ELightComponentType@@XZ)
18>VDirectionalLightComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual float __cdecl UDirectionalLightComponent::GetUniformPenumbraSize(void)const " (?GetUniformPenumbraSize@UDirectionalLightComponent@@UEBAMXZ)
18>Violets.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual float __cdecl UDirectionalLightComponent::GetUniformPenumbraSize(void)const " (?GetUniformPenumbraSize@UDirectionalLightComponent@@UEBAMXZ)
18>VDirectionalLightComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FLightSceneProxy * __cdecl UDirectionalLightComponent::CreateSceneProxy(void)const " (?CreateSceneProxy@UDirectionalLightComponent@@UEBAPEAVFLightSceneProxy@@XZ)
18>Violets.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FLightSceneProxy * __cdecl UDirectionalLightComponent::CreateSceneProxy(void)const " (?CreateSceneProxy@UDirectionalLightComponent@@UEBAPEAVFLightSceneProxy@@XZ)
18>VDirectionalLightComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UDirectionalLightComponent::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@UDirectionalLightComponent@@UEAAXAEAUFPropertyChangedEvent@@@Z)
18>Violets.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UDirectionalLightComponent::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@UDirectionalLightComponent@@UEAAXAEAUFPropertyChangedEvent@@@Z)
18>VDirectionalLightComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UDirectionalLightComponent::CanEditChange(class UProperty const *)const " (?CanEditChange@UDirectionalLightComponent@@UEBA_NPEBVUProperty@@@Z)
18>Violets.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UDirectionalLightComponent::CanEditChange(class UProperty const *)const " (?CanEditChange@UDirectionalLightComponent@@UEBA_NPEBVUProperty@@@Z)
18>VDirectionalLightComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UDirectionalLightComponent::Serialize(class FArchive &)" (?Serialize@UDirectionalLightComponent@@UEAAXAEAVFArchive@@@Z)
18>Violets.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UDirectionalLightComponent::Serialize(class FArchive &)" (?Serialize@UDirectionalLightComponent@@UEAAXAEAVFArchive@@@Z)
18>VDirectionalLightComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UDirectionalLightComponent::InvalidateLightingCacheDetailed(bool,bool)" (?InvalidateLightingCacheDetailed@UDirectionalLightComponent@@UEAAX_N0@Z)
18>Violets.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UDirectionalLightComponent::InvalidateLightingCacheDetailed(bool,bool)" (?InvalidateLightingCacheDetailed@UDirectionalLightComponent@@UEAAX_N0@Z)
Engine\Binaries\Win64\UE4Editor-Violets.dll : fatal error LNK1120: 8 unresolved externals


EDIT

It appears to be a part of the Engine module which is included in the dependency list by default, so now I’m pretty confused!

EDIT 2

I found the modules, they are located in the engine source code at:
UnrealEngine\Engine\Source\Runtime\

The methods failing to link are located in the engine runtime… Which is listed as a dependency.
How very odd.

EDIT 3

I can inherit UPointLightComponent without issue, as well as other components such as UStaticMeshComponent.

This leads me to believe this is a bug.

I have been able to find a thread from last year where someone was having the same issue, and it went unanswered, so this has been like this for some time.

OK, I went over the source code and changed



UCLASS(Blueprintable, ClassGroup=Lights, hidecategories=(Object, LightProfiles), editinlinenew, meta=(BlueprintSpawnableComponent), MinimalAPI)
class UDirectionalLightComponent : public ULightComponent
{
	GENERATED_UCLASS_BODY()


to



UCLASS(Blueprintable, ClassGroup = (Lights), hidecategories = (Object, LightProfiles), editinlinenew, meta = (BlueprintSpawnableComponent))
class ENGINE_API UDirectionalLightComponent : public ULightComponent
{
	GENERATED_UCLASS_BODY()


Which fixed the issue. Due to ‘MinimalAPI’, the engine was intentionally not exporting all of the methods of UDirectionalLightComponent. I suppose this does not qualify as a bug, however, I do believe that saving a (very?) small amount of engine compile time is not worth removing the ability to inherit UDirectionalLightComponent.

If I do end up submitting a pull request I will post that thread in here.