Failed to add class; unresolved external symbols

Running UE 4.7.2 and VS2013 Community.

Whenever I try to create a new ChildActorComponent class in the editor, I get the following error message:

Failed to add class SmallShip. Failed to automatically hot reload the ‘Spaceships’ module.

The compiler log provides the following output:

Info Parsing headers for SpaceshipsEditor
Info Reflection code generated for SpaceshipsEditor
Info Performing 3 actions (4 in parallel)
Info SmallShip.cpp
Info Spaceships.generated.cpp
Info [3/3] Link UE4Editor-Spaceships-1041.dll
Info    Creating library V:\Unreal Projects\Spaceships\Intermediate\Build\Win64\SpaceshipsEditor\Development\UE4Editor-Spaceships-1041.lib and object V:\Unreal Projects\Spaceships\Intermediate\Build\Win64\SpaceshipsEditor\Development\UE4Editor-Spaceships-1041.exp
Error SmallShip.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@UChildActorComponent@@UEAAXAEAUFPropertyChangedEvent@@@Z)
Error Spaceships.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@UChildActorComponent@@UEAAXAEAUFPropertyChangedEvent@@@Z)
Error SmallShip.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::PostEditUndo(void)" (?PostEditUndo@UChildActorComponent@@UEAAXXZ)
Error Spaceships.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::PostEditUndo(void)" (?PostEditUndo@UChildActorComponent@@UEAAXXZ)
Error SmallShip.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::OnComponentCreated(void)" (?OnComponentCreated@UChildActorComponent@@UEAAXXZ)
Error Spaceships.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::OnComponentCreated(void)" (?OnComponentCreated@UChildActorComponent@@UEAAXXZ)
Error SmallShip.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::OnComponentDestroyed(void)" (?OnComponentDestroyed@UChildActorComponent@@UEAAXXZ)
Error Spaceships.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::OnComponentDestroyed(void)" (?OnComponentDestroyed@UChildActorComponent@@UEAAXXZ)
Error SmallShip.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::OnRegister(void)" (?OnRegister@UChildActorComponent@@UEAAXXZ)
Error Spaceships.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UChildActorComponent::OnRegister(void)" (?OnRegister@UChildActorComponent@@UEAAXXZ)
Error SmallShip.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FActorComponentInstanceData * __cdecl UChildActorComponent::GetComponentInstanceData(void)const " (?GetComponentInstanceData@UChildActorComponent@@UEBAPEAVFActorComponentInstanceData@@XZ)
Error Spaceships.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FActorComponentInstanceData * __cdecl UChildActorComponent::GetComponentInstanceData(void)const " (?GetComponentInstanceData@UChildActorComponent@@UEBAPEAVFActorComponentInstanceData@@XZ)
Error SmallShip.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FName __cdecl UChildActorComponent::GetComponentInstanceDataType(void)const " (?GetComponentInstanceDataType@UChildActorComponent@@UEBA?AVFName@@XZ)
Error Spaceships.generated.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FName __cdecl UChildActorComponent::GetComponentInstanceDataType(void)const " (?GetComponentInstanceDataType@UChildActorComponent@@UEBA?AVFName@@XZ)
Error V:\Unreal Projects\Spaceships\Binaries\Win64\UE4Editor-Spaceships-1041.dll : fatal error LNK1120: 7 unresolved externals
Info -------- End Detailed Actions Stats -----------------------------------------------------------
Info ERROR: UBT ERROR: Failed to produce item: V:\Unreal Projects\Spaceships\Binaries\Win64\UE4Editor-Spaceships-1041.dll
Info Cumulative action seconds (8 processors): 0.00 building projects, 0.45 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.10 linking, 0.00 other
Info UBT execution time: 6.82 seconds

Any idea why the compiler is having trouble resolving those symbols? It looks like ChildActorComponent is part of the Engine module, and Engine is listed in my build file:

		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

I am also having this issue on 4.7.2 when adding a ChildActorComponent based class from the “Add New” menu. It also stops VS (I am using 2013 Ultimate) from building the solution successfully due to these link errors.

Removing the (PROJECTNAME)_API from the class declaration in the .h file of the component subclass stops the link errors for that file, but the (PROJECTNAME).generated.cpp.obj still generates the same link errors.

Hi,

This is due to the class being marked MinimalAPI rather than fully exported via ENGINE_API.

We have a bug open internally to check and fix deriving from some of our component class types, but if you’re building the engine from source, you can try removing the MinimalAPI from UChildActorComponent and then adding ENGINE_API to the class declaration (you can also remove ENGINE_API from any functions that are manually exported too).

Thanks,
Jamie.

How exactly do I do this? I didn’t compile Unreal from source, but I’m getting the same kind of error when I try to create a class deriving from Point Light.

UPointLight is also marked MinimalAPI, so you’re going to run into the same issues when deriving from it.

I asked around, and the general consensus is that you shouldn’t really be trying to derive from point light in the vast majority of cases, and it it instead advised to create a blueprint or class that contains a point light. Why do you need to derive from UPointLight?