Announcement

Collapse
No announcement yet.

Unresolved external symbol: inheriting from URadialForceComponent

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unresolved external symbol: inheriting from URadialForceComponent

    After inheriting from URadialForceComponent and trying to compile, I ended up with several unresolved external symbol errors.

    [.h]

    Code:
    #pragma once
    
    #include "PhysicsEngine/RadialForceComponent.h"
    #include "SF_RadialForceComponent.generated.h"
    
    /**
     * 
     */
    UCLASS()
    class SHOOTERGAME_API USF_RadialForceComponent : public URadialForceComponent
    {
    	GENERATED_BODY()
    
    	
    };
    [.cpp]

    Code:
    #include "ShooterGame.h"
    #include "SF_RadialForceComponent.h"
    After compilling:

    Code:
    1>Module.ShooterGame.1_of_3.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl URadialForceComponent::FireImpulse(void)" (?FireImpulse@URadialForceComponent@@UEAAXXZ)
    1>ShooterGame.generated.1.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl URadialForceComponent::FireImpulse(void)" (?FireImpulse@URadialForceComponent@@UEAAXXZ)
    1>ShooterGame.generated.2.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl URadialForceComponent::FireImpulse(void)" (?FireImpulse@URadialForceComponent@@UEAAXXZ)
    1>Module.ShooterGame.1_of_3.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl URadialForceComponent::AddObjectTypeToAffect(class TEnumAsByte<enum EObjectTypeQuery>)" (?AddObjectTypeToAffect@URadialForceComponent@@UEAAXV?$TEnumAsByte@W4EObjectTypeQuery@@@@@Z)
    1>ShooterGame.generated.1.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl URadialForceComponent::AddObjectTypeToAffect(class TEnumAsByte<enum EObjectTypeQuery>)" (?AddObjectTypeToAffect@URadialForceComponent@@UEAAXV?$TEnumAsByte@W4EObjectTypeQuery@@@@@Z)
    1>ShooterGame.generated.2.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl URadialForceComponent::AddObjectTypeToAffect(class TEnumAsByte<enum EObjectTypeQuery>)" (?AddObjectTypeToAffect@URadialForceComponent@@UEAAXV?$TEnumAsByte@W4EObjectTypeQuery@@@@@Z)
    1>Module.ShooterGame.1_of_3.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl URadialForceComponent::RemoveObjectTypeToAffect(class TEnumAsByte<enum EObjectTypeQuery>)" (?RemoveObjectTypeToAffect@URadialForceComponent@@UEAAXV?$TEnumAsByte@W4EObjectTypeQuery@@@@@Z)
    1>ShooterGame.generated.1.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl URadialForceComponent::RemoveObjectTypeToAffect(class TEnumAsByte<enum EObjectTypeQuery>)" (?RemoveObjectTypeToAffect@URadialForceComponent@@UEAAXV?$TEnumAsByte@W4EObjectTypeQuery@@@@@Z)
    1>ShooterGame.generated.2.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl URadialForceComponent::RemoveObjectTypeToAffect(class TEnumAsByte<enum EObjectTypeQuery>)" (?RemoveObjectTypeToAffect@URadialForceComponent@@UEAAXV?$TEnumAsByte@W4EObjectTypeQuery@@@@@Z)
    1>Module.ShooterGame.1_of_3.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)" (?TickComponent@URadialForceComponent@@MEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z)
    1>ShooterGame.generated.1.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)" (?TickComponent@URadialForceComponent@@MEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z)
    1>ShooterGame.generated.2.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)" (?TickComponent@URadialForceComponent@@MEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z)
    1>Module.ShooterGame.1_of_3.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::BeginPlay(void)" (?BeginPlay@URadialForceComponent@@MEAAXXZ)
    1>ShooterGame.generated.1.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::BeginPlay(void)" (?BeginPlay@URadialForceComponent@@MEAAXXZ)
    1>ShooterGame.generated.2.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::BeginPlay(void)" (?BeginPlay@URadialForceComponent@@MEAAXXZ)
    1>Module.ShooterGame.1_of_3.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::PostLoad(void)" (?PostLoad@URadialForceComponent@@MEAAXXZ)
    1>ShooterGame.generated.1.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::PostLoad(void)" (?PostLoad@URadialForceComponent@@MEAAXXZ)
    1>ShooterGame.generated.2.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::PostLoad(void)" (?PostLoad@URadialForceComponent@@MEAAXXZ)
    1>Module.ShooterGame.1_of_3.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@URadialForceComponent@@MEAAXAEAUFPropertyChangedEvent@@@Z)
    1>ShooterGame.generated.1.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@URadialForceComponent@@MEAAXAEAUFPropertyChangedEvent@@@Z)
    1>ShooterGame.generated.2.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::PostEditChangeProperty(struct FPropertyChangedEvent &)" (?PostEditChangeProperty@URadialForceComponent@@MEAAXAEAUFPropertyChangedEvent@@@Z)
    I'm using UE4 version 4.15.

    After doing some research, I found a 2 year-old Answerhub thread with exactly the same error, but with no clear solutions.

    Any thoughts? Thanks.

    [03-07-2017, 12:52 PM] EDIT:

    Silly me, I forgot to add the .cpp. Fixed.
    Last edited by MatheusRC; 03-07-2017, 08:54 AM.

  • replied
    This will furtherly be discussed in AnswerHub. Thanks for the help!

    Leave a comment:


  • replied
    I read about the MinimalAPI and was starting to suspect that. Thanks for confirming.

    With the knowledge I have at the moment I don't think it would be smart to change engine code. I'll try finding another solution.

    Thanks, Nico.

    Leave a comment:


  • replied
    This will sound disappointing, but I don't think URadialForceComponent is meant to be inherited from. If you look at its header file in the engine source, you see its symbols are not exported through the ENGINE_API macro and more importantly, the class is marked with MinimalAPI, which according to the documentation:

    Causes only the class's type information to be exported for use by other modules. The class can be cast to, but the functions of the class cannot be called (with the exception of inline methods). This improves compile times of exporting everything for classes that do not need all of their functions accessible in other modules.
    Source: https://docs.unrealengine.com/latest...rs/MinimalAPI/

    So the methods from URadialForceComponent are meant to be called only from inside the Engine module, which is why their symbols are missing from the static libraries that your code is trying to link against. You could technically roll your own build of the engine with this class publicly exported, but more likely you'll want to look at other ways to implement what you are trying to accomplish.

    Leave a comment:


  • replied
    I found a way of compilling it, but still got other issues.

    [.h]

    Code:
    #pragma once
    
    #include "PhysicsEngine/RadialForceComponent.h"
    #include "SF_RadialForceComponent.generated.h"
    
    /**
     * 
     */
    UCLASS(hidecategories = (Object, Mobility, LOD, Physics), ClassGroup = Physics, showcategories = Trigger, meta = (BlueprintSpawnableComponent))
    class SHOOTERGAME_API USF_RadialForceComponent : public URadialForceComponent
    {
    	GENERATED_BODY()
    
    	UFUNCTION(BlueprintCallable, Category = "Physics|Components|RadialForce")
    	void FireImpulse() override;
    
    	UFUNCTION(BlueprintCallable, Category = "Physics|Components|RadialForce")
    	void AddObjectTypeToAffect(TEnumAsByte<enum EObjectTypeQuery> ObjectType) override;
    
    	UFUNCTION(BlueprintCallable, Category = "Physics|Components|RadialForce")
    	void RemoveObjectTypeToAffect(TEnumAsByte<enum EObjectTypeQuery> ObjectType) override;
    
    protected:
    
    	void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
    	
    	void BeginPlay() override;
    
    	void PostLoad() override;
    
    #if WITH_EDITOR
    	void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
    #endif
    	
    };
    [.cpp]

    Code:
    #include "ShooterGame.h"
    #include "SF_RadialForceComponent.h"
    
    void USF_RadialForceComponent::FireImpulse()
    {
    }
    
    void USF_RadialForceComponent::AddObjectTypeToAffect(TEnumAsByte<EObjectTypeQuery> ObjectType)
    {
    }
    
    void USF_RadialForceComponent::RemoveObjectTypeToAffect(TEnumAsByte<EObjectTypeQuery> ObjectType)
    {
    }
    
    void USF_RadialForceComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
    {
    }
    
    void USF_RadialForceComponent::BeginPlay()
    {
    }
    
    void USF_RadialForceComponent::PostLoad()
    {
    }
    
    void USF_RadialForceComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
    {
    }
    The problem now is that I'm unable of using Super like this:

    Code:
    void USF_RadialForceComponent::BeginPlay()
    {
    	Super::BeginPlay();
    }
    The new error is also an unresolved external symbol:

    Code:
    1>Module.ShooterGame.1_of_3.cpp.obj : error LNK2019: unresolved external symbol "protected: virtual void __cdecl URadialForceComponent::BeginPlay(void)" (?BeginPlay@URadialForceComponent@@MEAAXXZ) referenced in function "protected: virtual void __cdecl USF_RadialForceComponent::BeginPlay(void)" (?BeginPlay@USF_RadialForceComponent@@MEAAXXZ)
    1>D:\UnrealEngineProjects\starfireproject_415\Binaries\Win64\UE4Editor-ShooterGame.dll : fatal error LNK1120: 1 unresolved externals

    Leave a comment:

Working...
X