Tuesday, October 6, 2015

unreal - Why do I get link errors when extending UBatchLineComponent in UE?


I got some link errors when extending UBatchLineComponent this way:


UCLASS(MinimalAPI)
class UPBLineBatchComponent : public ULineBatchComponent
{
GENERATED_UCLASS_BODY()
public:
virtual void UpdateBounds();

virtual FBoxSphereBounds CalcBounds(const FTransform& LocalToWorld) const override;
void SetTransform(const FTransform &Transform);
FBoxSphereBounds LocalBounds;
};

It gave me those errors:


Error   5   error LNK2001: unresolved external symbol "public: virtual class FPrimitiveSceneProxy * __cdecl ULineBatchComponent::CreateSceneProxy(void)" (?CreateSceneProxy@ULineBatchComponent@@UEAAPEAVFPrimitiveSceneProxy@@XZ)  C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\Module.ProBuilderPlugin.2_of_2.cpp.obj    ProBuilder
Error 6 error LNK2001: unresolved external symbol "public: virtual class FPrimitiveSceneProxy * __cdecl ULineBatchComponent::CreateSceneProxy(void)" (?CreateSceneProxy@ULineBatchComponent@@UEAAPEAVFPrimitiveSceneProxy@@XZ) C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\ProBuilderPlugin.generated.cpp.obj ProBuilder
Error 9 error LNK2001: unresolved external symbol "public: virtual void __cdecl ULineBatchComponent::ApplyWorldOffset(struct FVector const &,bool)" (?ApplyWorldOffset@ULineBatchComponent@@UEAAXAEBUFVector@@_N@Z) C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\Module.ProBuilderPlugin.2_of_2.cpp.obj ProBuilder
Error 10 error LNK2001: unresolved external symbol "public: virtual void __cdecl ULineBatchComponent::ApplyWorldOffset(struct FVector const &,bool)" (?ApplyWorldOffset@ULineBatchComponent@@UEAAXAEBUFVector@@_N@Z) C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\ProBuilderPlugin.generated.cpp.obj ProBuilder

Error 1 error LNK2001: unresolved external symbol "public: virtual void __cdecl ULineBatchComponent::DrawLine(struct FVector const &,struct FVector const &,struct FLinearColor const &,unsigned char,float,float)" (?DrawLine@ULineBatchComponent@@UEAAXAEBUFVector@@0AEBUFLinearColor@@EMM@Z) C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\Module.ProBuilderPlugin.2_of_2.cpp.obj ProBuilder
Error 2 error LNK2001: unresolved external symbol "public: virtual void __cdecl ULineBatchComponent::DrawLine(struct FVector const &,struct FVector const &,struct FLinearColor const &,unsigned char,float,float)" (?DrawLine@ULineBatchComponent@@UEAAXAEBUFVector@@0AEBUFLinearColor@@EMM@Z) C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\ProBuilderPlugin.generated.cpp.obj ProBuilder
Error 3 error LNK2001: unresolved external symbol "public: virtual void __cdecl ULineBatchComponent::DrawPoint(struct FVector const &,struct FLinearColor const &,float,unsigned char,float)" (?DrawPoint@ULineBatchComponent@@UEAAXAEBUFVector@@AEBUFLinearColor@@MEM@Z) C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\Module.ProBuilderPlugin.2_of_2.cpp.obj ProBuilder
Error 4 error LNK2001: unresolved external symbol "public: virtual void __cdecl ULineBatchComponent::DrawPoint(struct FVector const &,struct FLinearColor const &,float,unsigned char,float)" (?DrawPoint@ULineBatchComponent@@UEAAXAEBUFVector@@AEBUFLinearColor@@MEM@Z) C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\ProBuilderPlugin.generated.cpp.obj ProBuilder
Error 7 error LNK2001: unresolved external symbol "public: virtual void __cdecl ULineBatchComponent::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)" (?TickComponent@ULineBatchComponent@@UEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z) C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\Module.ProBuilderPlugin.2_of_2.cpp.obj ProBuilder
Error 8 error LNK2001: unresolved external symbol "public: virtual void __cdecl ULineBatchComponent::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)" (?TickComponent@ULineBatchComponent@@UEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z) C:\Users\Yvain\Documents\ProBuilder\Intermediate\ProjectFiles\ProBuilderPlugin.generated.cpp.obj ProBuilder

Answer



ULineBatchComponent is not fully-exported out of the engine module, so you can't subclass it like that (the symbols you are getting link errors for are not tagged with ENGINE_API, so they don't get exported, so they cannot be found at link time).


A better solution to this problem is to create your own component that delegates to a ULineBatchComponent member for all functionality except that which you're trying to alter (based on your other question, this is the bounding box computation).


You could also modify the engine source code to expose the type (remove ENGINE_API from all members of ULineBatchComponent and added it to the class itself, remove MinimalAPI from the UCLASS macro). This is probably a recipe for long-term pain, though.



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...