Lik error when creating a component inheriting from USphereComponent

Hello,

I wanted to create a new C++ class inheriting from SphereComponent.

First problem : in the editor, in the dialog which is opened after I choose File > Add Code to project, the SphereComponent class is not visible. I decided to choosed the StaticMeshComponent to at least have the basic includes, and changed the files accordingly to inherit from USphereComponent.

The problem I have is that when I build, I have linking errors :


29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UShapeComponent::GetUsedMaterials(class TArray<class UMaterialInterface *,class FDefaultAllocator> &)const " (?GetUsedMaterials@UShapeComponent@@UEBAXAEAV?$TArray@PEAVUMaterialInterface@@VFDefaultAllocator@@@@@Z)
29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class UBodySetup * __cdecl UShapeComponent::GetBodySetup(void)" (?GetBodySetup@UShapeComponent@@UEAAPEAVUBodySetup@@XZ)
29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UShapeComponent::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@UShapeComponent@@UEAAXAEAUFPropertyChangedEvent@@@Z)
29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FPrimitiveSceneProxy * __cdecl USphereComponent::CreateSceneProxy(void)" (?CreateSceneProxy@USphereComponent@@UEAAPEAVFPrimitiveSceneProxy@@XZ)
29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl USphereComponent::IsZeroExtent(void)const " (?IsZeroExtent@USphereComponent@@UEBA_NXZ)
29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FCollisionShape __cdecl USphereComponent::GetCollisionShape(float)const " (?GetCollisionShape@USphereComponent@@UEBA?AUFCollisionShape@@M@Z)
29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl USphereComponent::AreSymmetricRotations(class FQuat const &,class FQuat const &,class FVector const &)const " (?AreSymmetricRotations@USphereComponent@@UEBA_NAEBVFQuat@@0AEBVFVector@@@Z)
29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FBoxSphereBounds __cdecl USphereComponent::CalcBounds(class FTransform const &)const " (?CalcBounds@USphereComponent@@UEBA?AUFBoxSphereBounds@@AEBVFTransform@@@Z)
29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl USphereComponent::CalcBoundingCylinder(float &,float &)const " (?CalcBoundingCylinder@USphereComponent@@UEBAXAEAM0@Z)
29>BBHoopSphereComponent.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl USphereComponent::UpdateBodySetup(void)" (?UpdateBodySetup@USphereComponent@@UEAAXXZ)

Any idea of what is going wrong?

Thanks

Try this.


UCLASS(HeaderGroup=Component, ClassGroup=Shapes, editinlinenew, hidecategories=(Object,LOD,Lighting,TextureStreaming), meta=(BlueprintSpawnableComponent))
class ENGINE_API USphereComponent : public UShapeComponent

UCLASS(abstract, HeaderGroup=Component, hidecategories=(Object,LOD,Lighting,TextureStreaming,Activation,"Components|Activation"), editinlinenew, meta=(BlueprintSpawnableComponent), showcategories=(Mobility))
class ENGINE_API UShapeComponent : public UPrimitiveComponent



And remove the remaining ENGINE_API from these classes.

That was indeed the trick.

I had already found this answer in answerhub yesterday, but I can’t find it again anymore :confused:

Thanks anayway :slight_smile: