How do I use UCustomMeshComponent?

I’d like to make use of the code in UCustomMeshComponent, i’ve been following articles I’ve found online on how to get this building but I’m now seeing link errors.

The solution proposed by the articles below is the duplicate this code into a code file within my project, is there no way I could just get the code within the plugin to work without having to duplicate?


#include "CustomMeshComponent.h"

TSubobjectPtr<UCustomMeshComponent> mesh = PCIP.CreateDefaultSubobject<UCustomMeshComponent>(this, TEXT("CustomMesh"));


error LNK2019: unresolved external symbol “private: static class UClass * __cdecl UCustomMeshComponent::GetPrivateStaticClass(wchar_t const *)” (?GetPrivateStaticClass@UCustomMeshComponent@@CAPEAVUClass@@PEB_W@Z) referenced in function "public: class UCustomMeshComponent * __cdecl FPostConstructInitializeProperties::CreateDefaultSubobject(class UObject *,class FName,bool,bool,bool)const " (??$CreateDefaultSubobject@VUCustomMeshComponent@@V1@@FPostConstructInitializeProperties@@QEBAPEAVUCustomMeshComponent@@PEAVUObject@@VFName@@_N22@Z)



Hi Maddius,

It happens cause UCustomMeshComponent has no ENGINE_API in class declaration. But it creates some problem with linkage. As described here A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums It is better to reimplement UCustomMeshComponent.

  1. Add “InputCore”, “RHI”, “RenderCore”, “ShaderCore” to PublicDependencyModuleNames in CustomGame.Build.cs
  2. Just copy CustomMeshComponent.h/cpp to your custom project and replace Custom to somthing like Generated.
  3. TSubobjectPtr mesh = PCIP.CreateDefaultSubobject(this, TEXT("CustomMesh"));

Thanks for the reply, ideally we’d want to just reuse the existing code, but if duplication is the only way then OK.

To avoid duplication what else could we do? Could we move UCustomMeshComponent to somewhere that is can be shared across projects?


I research a little more about this question. I thought that UCustomMeshComponent is a part of engine,but it is part of CustomMeshPlugin. You should try CUSTOMMESHCOMPONENT_API instead of ENGINE_API.

class CUSTOMMESHCOMPONENT_API UCustomMeshComponent : public UMeshComponent

Let me know if it helps to you.

This seems to compile! I will run some further tests but perhaps this is worth submitting and updating the Wiki article? Since it would be best not to duplicate and have another dependency to update.

Thanks :slight_smile:

Hello Maddius,

We have added some information about how to solve link issue. If you see that problem not described in full size or you have some more information about your experience with UCustomMeshCompoent, please feel free to make any edits or additions to the wiki as you wish (you log in with the same credentials as the AnswerHub).

Best regards,

Hi. I have the same problem and I’ve seen your addition to the wiki page but I didn’t got it. Where I have to put that code? It is not very clear to me. :slight_smile: Any advice?

The file you need to change is here:


You need to add CUSTOMMESHCOMPONENT_API into the class definition so it looks like this:

class CUSTOMMESHCOMPONENT_API UCustomMeshComponent : public UMeshComponent

Formatting doesn’t like back slashes.



I’ve just tried working with the CustomMeshComponent, it builds OK however when the editor is loading up this appears:


What’s the best way to get this dll to automatically build correctly for my project?



Just copy this dll from plugins folder to binaries/win64

Best regards,

I have added CUSTOMMESHCOMPONENT_API to the CustomMeshComponent.h but still no luck. Do I need to do a full recompile of the engine itself afterwards or should it just work when I run my project?

Hi Scykopath, I was having the same issue however doing a compile on the engine seems to have fixed it. It wont recompile everything, just the changed source ie CustomMeshComponent

I’m late to the party but found a solution without copy/pasta or manually modifying my build file.

In the Unreal editor add a new C++ class and have it inherit from CustomMeshComponent. That will add your new class to the Visual Studio solution. You can now ignore/delete that class if you want, since adding it has properly included the CustomMeshComponent files into your external dependencies. Now you can include CustomMeshComponent.h to any class you want without errors about not finding/linking the files.

I successed to use UCustomMeshComponent in my project. It’s simple. Add “CustomMeshComponent” in to PublicDependencyModuleNames in Project.Build.cs. that’s all.