# Unresolved externals error with UChildActorComponent::CreateChildActor();

**URL:** <https://forums.unrealengine.com/t/unresolved-externals-error-with-uchildactorcomponent-createchildactor/292277>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [August 28, 2014, 6:27pm UTC](https://forums.unrealengine.com/t/unresolved-externals-error-with-uchildactorcomponent-createchildactor/292277 "2014-08-28T18:27:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamad.Empire\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hamad.Empire\_1](https://forums.unrealengine.com/u/Hamad.Empire_1)\
**Post date:** [August 28, 2014, 6:27pm UTC](https://forums.unrealengine.com/t/unresolved-externals-error-with-uchildactorcomponent-createchildactor/292277/1 "2014-08-28T18:27:42Z")

</div>

Hello,

So I’m trying to add components in C++, but in OnConstruction(), which is equivalent to the construction script in BP. I want to display temporary stuff by spawning some components whenever the user moves the BP actor in the scene.

Inside OnConstruction(), I have the following:

```
child = NewObject<UChildActorComponent>(this);
		
		if (child)
		{
			child->ChildActorClass = ATargetPoint::StaticClass();

			**child->CreateChildActor(); //<-------- problem here**

			child->AttachTo(RootComponent);

			child->RegisterComponent();

			child->bCreatedByConstructionScript = true;
		}

```

When I build, it throws this error:

error LNK2019: unresolved external symbol “public: void \_\_cdecl UChildActorComponent::CreateChildActor(void)” (?CreateChildActor@UChildActorComponent@@QEAAXXZ) referenced in function “public: virtual void \_\_cdecl ADilmunSplineSystem::OnConstruction(class FTransform const &)” (?OnConstruction@ADilmunSplineSystem@@UEAAXAEBVFTransform@@@Z)

Any Ideas why?

---

<div class="post-metadata">

**Author:** ![Hamad.Empire\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hamad.Empire\_1](https://forums.unrealengine.com/u/Hamad.Empire_1)\
**Post date:** [August 28, 2014, 7:54pm UTC](https://forums.unrealengine.com/t/unresolved-externals-error-with-uchildactorcomponent-createchildactor/292277/2 "2014-08-28T19:54:29Z")

</div>

I’m guessing that CreateChildActor() is not implemented, just declared in its .h file. Also, it’s not defined as a virtual void (so that I should implement it somewhere). My other guess is that this function is deprecated.

I want to basically acquire the functionality of " add ChildComponentActor" blueprint node, in C++.

Thanks!

---

<div class="post-metadata">

**Author:** ![Hamad.Empire\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hamad.Empire\_1](https://forums.unrealengine.com/u/Hamad.Empire_1)\
**Post date:** [August 29, 2014, 10:16am UTC](https://forums.unrealengine.com/t/unresolved-externals-error-with-uchildactorcomponent-createchildactor/292277/3 "2014-08-29T10:16:30Z")

</div>

So, any help?

---

<div class="post-metadata">

**Author:** ![VSZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VSZ](https://forums.unrealengine.com/u/VSZ)\
**Post date:** [December 19, 2014, 5:51pm UTC](https://forums.unrealengine.com/t/unresolved-externals-error-with-uchildactorcomponent-createchildactor/292277/4 "2014-12-19T17:51:44Z")

</div>

Did you manage to figure this out? I’m in the same boat as you. There seem to be a few threads on this topic but it’s not clear what the recommended C++ equivalent of AddChildComponentActor is.

---

<div class="post-metadata">

**Author:** ![VSZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VSZ](https://forums.unrealengine.com/u/VSZ)\
**Post date:** [December 19, 2014, 7:15pm UTC](https://forums.unrealengine.com/t/unresolved-externals-error-with-uchildactorcomponent-createchildactor/292277/5 "2014-12-19T19:15:56Z")

</div>

Reposting my answer from a [related thread](https://answers.unrealengine.com/questions/101002/uchildcomponentactor-createchildactor-compile-erro.html#answer-149739):

"I had the same issue, below worked for me:

Instead of CreateChildActor (which doesn’t seem accessible with the default build modules) manually call OnComponentCreated like this childActorComponent-\>OnComponentCreated();

There seems to be a bug where this particular function is not automatically called in C++ alone (the blueprint node AddChildActorComponent works fine) and the ChildActor within your component ends up never being created unless you use the manual workaround.

See this thread for more details: [https://answers.unrealengine.com/questions/41202/oncomponentcreated-not-called-when-using-createdef.html?sort=oldest](https://answers.unrealengine.com/questions/41202/oncomponentcreated-not-called-when-using-createdef.html?sort=oldest) "
