Announcement

Collapse
No announcement yet.

I get an "error LNK2019" when using ATriggerVolume in my code

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

    I get an "error LNK2019" when using ATriggerVolume in my code

    This snippet below throws an LNK2019 unresolved external symbol error when I build:

    Code:
    UGameplayStatics::GetAllActorsOfClass(this, ATriggerVolume::StaticClass(), outActors);
    But the same code works perfectly if I use the parent class AVolume instead of ATriggerVolume:

    Code:
    UGameplayStatics::GetAllActorsOfClass(this, AVolume::StaticClass(), outActors);

    Any ideas what could be causing this? I've tried all kinds of fixes for an hour now but I feel like I'm missing something very basic here

    I understand that AVolumeTrigger is a part of the module "Engine" which is already included in my build.cs file as shown below.

    Code:
    PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", });
    Full error is as follows:
    error LNK2019: unresolved external symbol "private: static class UClass * __cdecl ATriggerVolume::GetPrivateStaticClass(wchar_t const *)" (?GetPrivateStaticClass@ATriggerVolume@@CAPEAVUClass@@PEB_W@Z) referenced in function "class ATriggerVolume * __cdecl Cast<class ATriggerVolume>(class UObject *)" (??$Cast@VATriggerVolume@@@@YAPEAVATriggerVolume@@PEAVUObject@@@Z)

    Steam Early Access: Drunk On Nectar - The Nature Simulator

    UE4 Plugins: DoN’s Dynamic Mesh FX | DoN’s 3D Pathfinding

    #2
    TriggerVolume is not marked as an exported class. You could add MinimalAPI to the UCLASS macro of ATriggerVolume if you are compiling your own engine code.

    You could also do UClass* TriggerVolumeClass = FindObject<UClass>(ANY_PACKAGE, TEXT("TriggerVolume")); to get the class. Not ideal, but will get you the UClass* you want.

    Comment


      #3
      Thanks, that works. I'd erroneously assumed that classes for widely used components would be available OOTB. Even with the UClass workaround I can't cast the outActors" back to a TriggerVolume unless that class is exported, right?

      Anyway for my purposes I should be able to get away with casting the results to AVolume.

      Steam Early Access: Drunk On Nectar - The Nature Simulator

      UE4 Plugins: DoN’s Dynamic Mesh FX | DoN’s 3D Pathfinding

      Comment


        #4
        Originally posted by Marc Audy View Post
        TriggerVolume is not marked as an exported class. You could add MinimalAPI to the UCLASS macro of ATriggerVolume if you are compiling your own engine code.

        You could also do UClass* TriggerVolumeClass = FindObject<UClass>(ANY_PACKAGE, TEXT("TriggerVolume")); to get the class. Not ideal, but will get you the UClass* you want.
        Does that mean that we cannot create a subclass from ATriggerVolume? I'm trying to do this and it won't link. Any work-arounds without recompiling the engine? I am able to create a subclass from the ATriggerBox class instead and it looks the same. Is there any major differences between ATriggerVolume and ATriggerBox?
        Last edited by LethalEncounter; 09-22-2014, 10:30 PM.

        Comment


          #5
          Originally posted by LethalEncounter View Post
          Does that mean that we cannot create a subclass from ATriggerVolume? I'm trying to do this and it won't link. Any work-arounds without recompiling the engine? I am able to create a subclass from the ATriggerBox class instead and it looks the same. Is there any major differences between ATriggerVolume and ATriggerBox?
          It sure sounds like it. I had a similar requirement and I ended up creating an Actor class with an appropriate shape component (BoxComponent / SphereComponent/ etc) to serve as a trigger volume. Not sure if someone else is aware of a workaround to subclass unexported classes without tagging them for export and recompiling the engine. Would love to know of one.

          Steam Early Access: Drunk On Nectar - The Nature Simulator

          UE4 Plugins: DoN’s Dynamic Mesh FX | DoN’s 3D Pathfinding

          Comment


            #6
            I'm guessing there's a good reason for it, be interesting to know what it is. Mind you, Trigger Volumes shouldn't be all that difficult to reproduce are they?

            Comment

            Working...
            X