# Using Haxe from C++ and being careful with the GC

**URL:** https://community.haxe.org/t/using-haxe-from-c-and-being-careful-with-the-gc/3984
**Category:** Haxe
**Tags:** haxe-cpp
**Created:** [June 28, 2023, 7:21pm UTC](https://community.haxe.org/t/using-haxe-from-c-and-being-careful-with-the-gc/3984 "2023-06-28T19:21:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![singpolyma](https://community.haxe.org/user_avatar/community.haxe.org/singpolyma/32/2193_2.png) [@singpolyma](https://community.haxe.org/u/singpolyma)
#### Post date: [June 28, 2023, 7:21pm UTC](https://community.haxe.org/t/using-haxe-from-c-and-being-careful-with-the-gc/3984/1 "2023-06-28T19:21:01Z")

</div>

I am writing a library in Haxe that I would like to use from C++. What do I need do to C++ side with references I get back from Haxe method calls to be sure the GC knows they are still live?

---

<div class="post-metadata">

### Author: ![neimanpinchas](https://community.haxe.org/user_avatar/community.haxe.org/neimanpinchas/32/2348_2.png) [@neimanpinchas](https://community.haxe.org/u/neimanpinchas)
#### Post date: [June 28, 2023, 8:52pm UTC](https://community.haxe.org/t/using-haxe-from-c-and-being-careful-with-the-gc/3984/2 "2023-06-28T20:52:53Z")

</div>

> **[GitHub - RobertBorghese/reflaxe.CPP: An alternative C++ target for Haxe that...](https://github.com/RobertBorghese/reflaxe.CPP)**
>
> An alternative C++ target for Haxe that generates dependent-less, GC-less C++17 code. - GitHub - RobertBorghese/reflaxe.CPP: An alternative C++ target for Haxe that generates dependent-less, GC-les...

---

<div class="post-metadata">

### Author: ![RoBBoR](https://community.haxe.org/user_avatar/community.haxe.org/robbor/32/1881_2.png) [@RoBBoR](https://community.haxe.org/u/RoBBoR)
#### Post date: [June 28, 2023, 10:49pm UTC](https://community.haxe.org/t/using-haxe-from-c-and-being-careful-with-the-gc/3984/3 "2023-06-28T22:49:02Z")

</div>

Thanks for the link to my project!! But maybe not what this is what this person is looking for. 😅

It’s pretty undocumented, but there are some resources. I’d recommend reading this article and the ones before it (might be out of date??): [hxcpp-guide/work-in-progress/build/5.1-building-a-wrapped-dynamic-library.md at master · snowkit/hxcpp-guide · GitHub](https://github.com/snowkit/hxcpp-guide/blob/master/work-in-progress/build/5.1-building-a-wrapped-dynamic-library.md)

I’d also recommend studying [HxGodot](https://github.com/HxGodot/hxgodot/), which generates a C++ binary that can have its functions called arbitrarily, but might have to dig through it.
