# How do I use UCustomMeshComponent?

**URL:** <https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391>\
**Category:** World Creation\
**Tags:** Procedural-Generation, unreal-engine, procedural-mesh, CPP, question\
**Created:** [October 27, 2014, 1:12pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391 "2014-10-27T13:12:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [October 27, 2014, 1:12pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/1 "2014-10-27T13:12:00Z")

</div>

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?

Code:

```
#include "CustomMeshComponent.h"

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

```

Error:

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)

Articles:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

> **[Using a plugin in C++ code](https://forums.unrealengine.com/questions/13691/using-a-plugin-in-c-code.html)**
>
> Hi, I want to use a plugin which is available in the engine source tree. Exactly that is: Engine/Plugins/Runtime/CustomMeshComponent How can I do that? More details: In a fresh project the UCustomMeshComponent class is not visible for the...

Thanks

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_957a4452](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_957a4452](https://forums.unrealengine.com/u/anonymous_user_957a4452)\
**Post date:** [October 28, 2014, 1:23pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/2 "2014-10-28T13:23:34Z")

</div>

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](https://wiki.unrealengine.com/Procedural_Mesh_Generation) 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"));`

---

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [October 28, 2014, 3:46pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/3 "2014-10-28T15:46:25Z")

</div>

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?

Thanks

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_957a4452](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_957a4452](https://forums.unrealengine.com/u/anonymous_user_957a4452)\
**Post date:** [October 28, 2014, 4:44pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/4 "2014-10-28T16:44:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [October 28, 2014, 5:52pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/5 "2014-10-28T17:52:35Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_957a4452](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_957a4452](https://forums.unrealengine.com/u/anonymous_user_957a4452)\
**Post date:** [October 30, 2014, 1:31pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/6 "2014-10-30T13:31:35Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![thek3nger\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thek3nger\_1](https://forums.unrealengine.com/u/thek3nger_1)\
**Post date:** [October 30, 2014, 10:56pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/7 "2014-10-30T22:56:51Z")

</div>

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. 🙂 Any advice?

---

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [October 31, 2014, 12:53am UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/8 "2014-10-31T00:53:30Z")

</div>

The file you need to change is here:

\UnrealEngine\Engine\Plugins\Runtime\CustomMeshComponent\Source\CustomMeshComponent\Classes\CustomMeshComponent.h

You need to add CUSTOMMESHCOMPONENT\_API into the class definition so it looks like this:

class CUSTOMMESHCOMPONENT\_API UCustomMeshComponent : public UMeshComponent

---

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [October 31, 2014, 12:55am UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/9 "2014-10-31T00:55:24Z")

</div>

Formatting doesn’t like back slashes.

```
<RootDirectory>\UnrealEngine\Engine\Plugins\Runtime\CustomMeshComponent\Source\CustomMeshComponent\Classes
```

---

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [November 2, 2014, 3:57pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/10 "2014-11-02T15:57:47Z")

</div>

Hey,

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

![19802-untitled.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/0/2/e02b19c6370fa2db1ff3061bbf81a12e227da913.png)

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

Thanks

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_957a4452](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_957a4452](https://forums.unrealengine.com/u/anonymous_user_957a4452)\
**Post date:** [November 4, 2014, 8:42am UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/11 "2014-11-04T08:42:21Z")

</div>

Hi,

Just copy this dll from plugins folder to binaries/win64

Best regards,

---

<div class="post-metadata">

**Author:** ![TheVexix](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheVexix](https://forums.unrealengine.com/u/TheVexix)\
**Post date:** [January 20, 2015, 5:11am UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/12 "2015-01-20T05:11:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![HJRS](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HJRS](https://forums.unrealengine.com/u/HJRS)\
**Post date:** [January 20, 2015, 10:07am UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/13 "2015-01-20T10:07:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_3d61dbcf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3d61dbcf](https://forums.unrealengine.com/u/anonymous_user_3d61dbcf)\
**Post date:** [July 4, 2015, 1:44pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/14 "2015-07-04T13:44:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Anonymous\_570bd67d9cf28488acfb6317e4e5130b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_570bd67d9cf28488acfb6317e4e5130b](https://forums.unrealengine.com/u/Anonymous_570bd67d9cf28488acfb6317e4e5130b)\
**Post date:** [June 25, 2017, 12:29pm UTC](https://forums.unrealengine.com/t/how-do-i-use-ucustommeshcomponent/297391/15 "2017-06-25T12:29:33Z")

</div>

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