Announcement

Collapse
No announcement yet.

Declaring FSlateBrush causing build errors, tried all forms of declarations. Engine version 4.20.3.

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

    Declaring FSlateBrush causing build errors, tried all forms of declarations. Engine version 4.20.3.

    So, when I'm declaring it directly as an object in the header file I get lots of linker issues:

    Code:
    2>PickUpActor.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FSlateBrush::FSlateBrush(void)" (__imp_??0FSlateBrush@@QEAA@XZ) referenced in function "public: __cdecl APickUpActor::APickUpActor(void)" (??0APickUpActor@@QEAA@XZ)
    
    2>PickUpActor.gen.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl FSlateBrush::FSlateBrush(void)" (__imp_??0FSlateBrush@@QEAA@XZ)
    
    2>PickUpActor.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl FSlateBrush::~FSlateBrush(void)" (__imp_??1FSlateBrush@@UEAA@XZ) referenced in function "public: virtual __cdecl APickUpActor::~APickUpActor(void)" (??1APickUpActor@@UEAA@XZ)
    
    2>InventoryComponent.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl FSlateBrush::~FSlateBrush(void)" (__imp_??1FSlateBrush@@UEAA@XZ)
    
    2>PickUpActor.gen.cpp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl FSlateBrush::~FSlateBrush(void)" (__imp_??1FSlateBrush@@UEAA@XZ)
    When I add a UPROPERTY(EditAnywhere) I get this in addition to the previous:

    Code:
    2>PickUpActor.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UScriptStruct * __cdecl Z_Construct_UScriptStruct_FSlateBrush(void)" (__imp_?Z_Construct_UScriptStruct_FSlateBrush@@YAPEAVUScriptStruct@@XZ) referenced in function "void __cdecl `dynamic initializer for 'public: static struct UE4CodeGen_Private::FStructPropertyParams const Z_Construct_UClass_APickUpActor_Statics::NewProp_brush''(void)" (??__E?NewProp_brush@Z_Construct_UClass_APickUpActor_Statics@@2UFStructPropertyParams@UE4CodeGen_Private@@B@@YAXXZ)
    So, lets try and declare a FSlateRush pointer instead, without the UPROPERTY macro ... HUUURRAAAY, IT BUILDS! Lets try and add a UPROPERTY so I can actually choose an image in the editor: UPROPERTY(EditAnywhere). Now it doesn't build again, this time with completely different errors:

    Code:
    2>C:/Repos/Remnant/Source/Remnant/PuzzleSystem/Actors/PickUpActor.h(34): error : Inappropriate '*' on variable of type 'FSlateBrush', cannot have an exposed pointer to this type.
    I've even tried to hack it and declare it as a:
    Code:
    UPROPERTY(EditAnywhere)
    TSubClassOf<FSlateBrush> brush;
    this way I could just cast it to the FSlateBrush class when using it, however, now I get these errors:

    Code:
    2>C:/Repos/Remnant/Source/Remnant/PuzzleSystem/Actors/PickUpActor.h(34): error : Class 'FSlateBrush' not found.
    The use-case for this: Add brushes to pickup items, so that they can affect my Inventory icons in the UI. The plan is to get a pointer to my UMG widget, then the inventory icon image and set it's brush to the latest pickups' brush.

    To clear some things out; yes I have included the brush's header
    Code:
    #include "Styling/SlateBrush.h"
    in my own header file, I'm also declaring my brush variable in my header file, I've tried both in public and private with the same results. I've also tried it in both actor classes and actor component classes with the same result.

    My engine version is 4.20.3, I have no idea how to fix this or procede, help is extremely appreciated!
    Last edited by MLarsson98; 10-11-2018, 05:20 AM. Reason: Edit formating slightly

    #2
    For future references if anyone else has the same issues and I had. Take a look in your "Projectname.Build.cs". In there you will find:

    Code:
    // Uncomment if you are using Slate UI
    // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

    Comment

    Working...
    X