Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to initialize project components #6

Closed
StenBone opened this issue Dec 31, 2014 · 3 comments
Closed

How to initialize project components #6

StenBone opened this issue Dec 31, 2014 · 3 comments

Comments

@StenBone
Copy link

I am trying to use UBrickGridComponent in my BrickGrid class which is based off of the BrickGrid blueprint.

In my header:

TSubobjectPtr<class UBrickGridComponent> BrickGridComp;

In the constructor of my source file:

BrickGridComp = ObjectInitializer.CreateDefaultSubobject<UBrickGridComponent>(this, TEXT("BrickGridComp"));

The project builds the header properly, but throws an error when trying to run the source file. I have other components in my project which compile fine, when using similar syntax. What do you think is the problem? Is there another way to initialize this component?

Error Message:

error LNK2019: unresolved external symbol "private: static class UClass * __cdecl UBrickGridComponent::GetPrivateStaticClass(wchar_t const *)" (?GetPrivateStaticClass@UBrickGridComponent@@CAPEAVUClass@@PEB_W@Z) referenced in function "private: __cdecl ABrickGrid::ABrickGrid(class FObjectInitializer const &)" (??0ABrickGrid@@Aeaa@AEBVFObjectInitializer@@@z) C:\Users\Ben\Desktop\BrickGame-master\BrickGame-master\Intermediate\ProjectFiles\BrickGrid.cpp.obj

@StenBone
Copy link
Author

StenBone commented Jan 1, 2015

I changed the constructor, but still got the same error.

ABrickGrid::ABrickGrid(const class FPostConstructInitializeProperties& PCIP)
    : Super(PCIP)
{
    PrimaryActorTick.bCanEverTick = true;
    BrickGridComp = PCIP.CreateDefaultSubobject<UBrickGridComponent>(this, TEXT("BrickGridComp"));
}

I am really confused as to what is wrong.

@AndrewScheidecker
Copy link
Owner

I think this is a case of the UBrickGridComponent definition missing the BRICKGRID_API qualifier. Try changing it to this:
class BRICKGRID_API UBrickGridComponent : public USceneComponent
Let me know if that works and I'll make the change in the master branch.

@StenBone
Copy link
Author

StenBone commented Jan 1, 2015

Your instructions worked @AndrewScheidecker! I was beginning to think that I would never sort out that bug.

I put BRICKGRID_API in the right place just as you demonstrated in your reply above and removed BRICKGRID_API from the method declarations within the UBrickGridComponent class declaration in the header and now it works perfectly.

Thank you for the help @AndrewScheidecker and happy new year!

@StenBone StenBone closed this as completed Jan 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants