# Support with embedding julia in C++

**URL:** <https://discourse.julialang.org/t/support-with-embedding-julia-in-c/5054>\
**Category:** General Usage\
**Created:** [July 25, 2017, 11:34am UTC](https://discourse.julialang.org/t/support-with-embedding-julia-in-c/5054 "2017-07-25T11:34:44Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Amin\_Yahyaabadi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amin_yahyaabadi/32/9826_2.png) [@Amin\_Yahyaabadi](https://discourse.julialang.org/u/Amin_Yahyaabadi)\
**Post date:** [August 4, 2019, 10:46pm UTC](https://discourse.julialang.org/t/support-with-embedding-julia-in-c/5054/13 "2019-08-04T22:46:02Z")

</div>

If anyone is reading this later, go to these to links:

Calling Julia functions from C++:

> **[GitHub - JuliaInterop/CxxWrap.jl: Package to make C++ libraries available in...](https://github.com/JuliaInterop/CxxWrap.jl#calling-julia-functions-from-c)**
>
> Package to make C++ libraries available in Julia. Contribute to JuliaInterop/CxxWrap.jl development by creating an account on GitHub.

and  
[Embedding Julia](https://docs.julialang.org/en/v1/manual/embedding/index.html#Embedding-Julia-1)  
Here is the example on GitHub:  
[embedding example](https://github.com/JuliaLang/julia/tree/master/test/embedding)

and these threads:

> [@Calling my own Julia module from C](https://discourse.julialang.org/t/calling-my-own-julia-module-from-c/23779/2):
>
> I don’t have too much experience with this but I’ve gotten it to work. I found [this thread](https://discourse.julialang.org/t/calling-jl-gc-push1-multiple-times/18666) very helpful. The thread is about dealing with garbage collection when calling julia from C but the first post has a good example of loading a module from C (C++ actually but I think everything there works in C) and then calling a function from that module. I’ve used that approach to call my own modules from C. As far as I can tell loading modules is not in the embedding documentation though so I’m not su…

> [@Calling JL\_GC\_PUSH1 multiple times](https://discourse.julialang.org/t/calling-jl-gc-push1-multiple-times/18666/3):
>
> Well, I am going to describe what I did here, because I am finding very difficult to obtain clear information about the process of embedding Julia into C++ (when I get better, I will submit a PR to improve the documentation). (Please, correct me if I am wrong!) In fact, Julia will not GCed a variable if it is referenced somewhere. Since I want a variable inside a C++ class to not be freed, I need to make it global or add it reference to a global object. Since the second option seems better, I …

---

_[View the full topic](https://discourse.julialang.org/t/support-with-embedding-julia-in-c/5054)._
