# Problems embedding Julia in C++

**URL:** <https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455>\
**Category:** General Usage\
**Created:** [April 12, 2020, 6:40pm UTC](https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455 "2020-04-12T18:40:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [April 12, 2020, 6:40pm UTC](https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455/1 "2020-04-12T18:40:56Z")

</div>

Hello!

I am properly making a small mistake somewhere, but basically I am using CMake to try to include Julia capabilities in my cpp project. What I have in my CMakeLists.txt for that specific part of the project is:

```julia
include_directories("/opt/julia-1.4.0/include/julia/")

```

Which makes it so that I am able to correctly find “julia.h”. The problem arises though when I want to use any functionality, for example, “jl\_init()”:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/2/e2a23727f9edc725a5fdf47f8e569b9cd894ba95.png)

And I am unsure on how to go from here. I have tried reading the wiki, but there is something I probably have misunderstood. Any suggestions on how to move forward?

Kind regards

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [April 12, 2020, 6:46pm UTC](https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455/2 "2020-04-12T18:46:51Z")

</div>

I don’t know CMake, however to me that looks like you are not linking with `libjulia.so`. Did you tell CMake to link with it?

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [April 12, 2020, 7:08pm UTC](https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455/3 "2020-04-12T19:08:01Z")

</div>

You are completely right! Spared me a few hours of extra headache 🙂

Do you have any suggestions for which version to use, I can find three;

![image](https://global.discourse-cdn.com/julialang/original/3X/3/9/3991fd46247999c2506ba48b8261128a52ebaca4.png)

EDIT: there is only two, the last was a folder. EDIT2: No there is three I was wrong

Also I guess, that since I am using a .so now, if I ever send my application to someone else, they would also need the .so object? And then it has to comply with Julia’s license?

Kind regards

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [April 12, 2020, 7:13pm UTC](https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455/4 "2020-04-12T19:13:39Z")

</div>

I suspect they are all symbolic links to the same file (libjulia.so)…Linking with libjulia.so.1.4 ensures that it **only** runs with Julia 1.4…so you would have to change the linkage if you wanted to upgrade to 1.5, etc. Linking to libjulia.so would link to whatever version of julia they have…which may not be what you want.

Not sure about the license thing, I suspect the license is pretty liberal…I mean the code is licensed under the MIT license.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [April 12, 2020, 7:22pm UTC](https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455/5 "2020-04-12T19:22:27Z")

</div>

I see, seems like a reasonable assumption, will stick with the common one.

And true, if if gets that far I will have to look into licensing a bit more. But once again, thank you very much

Kind regards

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [April 12, 2020, 7:25pm UTC](https://discourse.julialang.org/t/problems-embedding-julia-in-c/37455/6 "2020-04-12T19:25:37Z")

</div>

You can always make a requirement of your program that they install Julia…It avoid the license issue when they install it from the site. 🙂
