Linker Errors Trying to Extend UBoxComponent

Dear Friends at Epic,

I am trying to extend UBoxComponent in a regular game module context!

Getting Linker Errors!

Any ideas of what to add to build.cs ?

// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "Components.h"

#include "Draw3DComp.generated.h"
 
UCLASS(dependson=UVictoryCore)
class UDraw3DComp : public UBoxComponent
{
	GENERATED_UCLASS_BODY()

};



1>Module.VictoryGame.1_of_5.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)

1>Module.VictoryGame.1_of_5.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class UBodySetup * __cdecl UShapeComponent::GetBodySetup(void)" (?GetBodySetup@UShapeComponent@@UEAAPEAVUBodySetup@@XZ)

1>Module.VictoryGame.1_of_5.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UShapeComponent::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@UShapeComponent@@UEAAXAEAUFPropertyChangedEvent@@@Z)

1>Module.VictoryGame.1_of_5.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl UBoxComponent::IsZeroExtent(void)const " (?IsZeroExtent@UBoxComponent@@UEBA_NXZ)

1>Module.VictoryGame.1_of_5.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FPrimitiveSceneProxy * __cdecl UBoxComponent::CreateSceneProxy(void)" (?CreateSceneProxy@UBoxComponent@@UEAAPEAVFPrimitiveSceneProxy@@XZ)

1>Module.VictoryGame.1_of_5.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FCollisionShape __cdecl UBoxComponent::GetCollisionShape(float)const " (?GetCollisionShape@UBoxComponent@@UEBA?AUFCollisionShape@@M@Z)

1>Module.VictoryGame.1_of_5.cpp.obj : error LNK2001: unresolved external symbol "public: virtual struct FBoxSphereBounds __cdecl UBoxComponent::CalcBounds(class FTransform const &)const " (?CalcBounds@UBoxComponent@@UEBA?AUFBoxSphereBounds@@AEBVFTransform@@@Z)

1>Module.VictoryGame.1_of_5.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl UBoxComponent::UpdateBodySetup(void)" (?UpdateBodySetup@UBoxComponent@@UEAAXXZ)

I believe this is the same problem as this question: Link error when creating a component inheriting from USphereComponent - Community & Industry Discussion - Epic Developer Community Forums.

The problem is that neither the class nor method is marked as being exported in the UShapComponent header. Adding it yourself for now should fix the problem.

Just to add to this, UBoxComponent, USphereComponent and UCapsuleComponent are all marked as ENGINE_API in 4.1, so this problem will be resolved.

excellent thank you Andrew!

:slight_smile:

Rama

Hi,

I just found this page because of a similar link issue in 4.1.0 when trying to use UBoxComponent as a base class and wanted to note that I still got the UShapeComponent link errors until I removed ‘MinimalApi’ from the UShapeComponent’s UCLASS macro and added ENGINE_API between the keyword class and UShapeComponent.

This issue still seems to occur even in 4.2.0 when extending UBoxComponent.

Can we expect a fix for this anytime soon or is there a reason this still isn’t changed?

I agree that this issue still exists, I experienced it just recently trying to extend USphereComponent

Rama

I can confirm this still happens in 4.2.1 with USphereComponent.

Hi!

I’ve checked the logs and it appears that UShapeComponent wasn’t marked as ENGINE_API until May 22nd, which looks like it just missed the 4.2 branch :frowning: The commit I was referring to before which was intended to fix the issue looks like it missed one of the base classes (it’s here).

If you want to make this work for now, feel free to cherry-pick this commit into your 4.2 checkout.

Hi Andrew

Thanks for your answer.

I’ll try adding this commit into my branch and see if it works.

You have to add “RHI” to PublicDependencyModuleNames in the Myprojectname.Build.cs file.