# How to Call C++ function from Blueprint?

**URL:** <https://forums.unrealengine.com/t/how-to-call-c-function-from-blueprint/453335>\
**Category:** Blueprint\
**Tags:** casting, unreal-engine, UE4, question, Blueprint, CPP\
**Created:** [August 4, 2019, 11:11am UTC](https://forums.unrealengine.com/t/how-to-call-c-function-from-blueprint/453335 "2019-08-04T11:11:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bazzy2000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bazzy2000](https://forums.unrealengine.com/u/Bazzy2000)\
**Post date:** [August 4, 2019, 11:11am UTC](https://forums.unrealengine.com/t/how-to-call-c-function-from-blueprint/453335/1 "2019-08-04T11:11:18Z")

</div>

I’m trying to use my simple “PrintText” function that I have created for test in c++ to call from blueprint but I’m getting an error every time I try to call the “PrintText” function from Blueprint. I don’t know what should be the **target** or the **object** after casting. The MyBlueprintFunctionLibrary is inheriting from UBlueprintFunctionLibrary. Any Help?

I’m trying to call the “PrintText” function from the “Level Blueprint”.

MyBlueprintFunctionLibrary.h

 ![284101-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/b/e/cbe7d32da365acc5b53d645e393d3b748ddfd5cf.png)

MyBlueprintFunctionLibrary.cpp

 ![284102-4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/e/5/0e5a915272b2262d7e9813ce0284dd8b5faf8a93.png)

Before casting to MyBlueprintFunctionLibrary. **Target** is unknown.

 ![284103-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/8/c/18c7fa8406eb8942f924309e02d0ed24fbbbab6d.png)

After casting to MyBlueprintFunctionLibrary. What should be the **Object**?

 ![284104-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/a/2/7a2b0c8f7e11d7ca58829065a2d2671a452b3d50.png)

---

<div class="post-metadata">

**Author:** ![xyah1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xyah1](https://forums.unrealengine.com/u/xyah1)\
**Post date:** [August 4, 2019, 1:38pm UTC](https://forums.unrealengine.com/t/how-to-call-c-function-from-blueprint/453335/2 "2019-08-04T13:38:49Z")

</div>

Functions inside a Function Library class should be static 🙂

---

<div class="post-metadata">

**Author:** ![Bazzy2000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bazzy2000](https://forums.unrealengine.com/u/Bazzy2000)\
**Post date:** [August 4, 2019, 1:42pm UTC](https://forums.unrealengine.com/t/how-to-call-c-function-from-blueprint/453335/3 "2019-08-04T13:42:22Z")

</div>

Yes, I know if I make the function static then there is no need to specify its target, but I would like to know, how can I call a C++ function from blueprint when it’s not static?

---

<div class="post-metadata">

**Author:** ![xyah1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xyah1](https://forums.unrealengine.com/u/xyah1)\
**Post date:** [August 4, 2019, 1:48pm UTC](https://forums.unrealengine.com/t/how-to-call-c-function-from-blueprint/453335/4 "2019-08-04T13:48:19Z")

</div>

Well, then you make a class that is not a Function Library, such as an Actor class!  
Then you don’t need to make it static since the Target will be the actor you create from that Actor class.

Blueprint Function libraries do not have an object that you can Target it. It’s a class that provides global functions therefore they must be static.

---

<div class="post-metadata">

**Author:** ![GarnerP57](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarnerP57](https://forums.unrealengine.com/u/GarnerP57)\
**Post date:** [August 4, 2019, 1:49pm UTC](https://forums.unrealengine.com/t/how-to-call-c-function-from-blueprint/453335/5 "2019-08-04T13:49:13Z")

</div>

The function library is a utility class meant to be called from anywhere and therefore static, while any regular class don’t normally use static functions and can be called if they are BlueprintCallable and you have a reference.

---

<div class="post-metadata">

**Author:** ![Dufwine](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dufwine](https://forums.unrealengine.com/u/Dufwine)\
**Post date:** [April 1, 2022, 3:12pm UTC](https://forums.unrealengine.com/t/how-to-call-c-function-from-blueprint/453335/6 "2022-04-01T15:12:37Z")

</div>

To use this function in Blueprint, just use the tag UFUNCTION(BlueprintCallable), like GarnerP57 said. This should work 🙂
