# Embedding multiple versions of Julia in a single C application

**URL:** https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133
**Category:** General Usage
**Tags:** question
**Created:** [January 24, 2022, 3:58pm UTC](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133 "2022-01-24T15:58:45Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![cariocecus](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@cariocecus](https://discourse.julialang.org/u/cariocecus)
#### Post date: [January 24, 2022, 3:58pm UTC](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133/1 "2022-01-24T15:58:45Z")

</div>

Dear Julia community,

I have a C application that calls code that was developed in Julia 0.3.12 (hereafter called old code). I do this by following the guidelines of the [Embedding Julia](https://docs.julialang.org/en/v1/manual/embedding/#Embedding-Julia) section of the manual.

Now I need to extend the C application to access some new functionality developed in Julia 1.0.5 (hereafter called new code).

The old code does not work with Julia 1.0.5 and the new code run with Julia 0.3.12, so it seems that my C application would need to be able to embed both Julia 0.3.12 and 1.0.5.

Assuming that I manage to deal with all the dynamic linking difficulties, such that every function call in my C code knows exactly which Julia version it refers to (and this is at this point a big assumption for me), is it safe to have two versions of Julia executing simultaneously in the same application?

I would appreciate any reference to another post or project that has had the same problem or a similar one.

Best regards

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [January 24, 2022, 4:17pm UTC](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133/2 "2022-01-24T16:17:11Z")

</div>

It’s definitely possible to do a Julia embedding which can dynamically load one out of multiple versions of Julia. Loading more than one version at the same time sounds unlikely to work though, at least it’s far beyond my skills.

Unless you’re talking of a huge code base, or you have way more C than Julia skills available, I would absolutely recommend updating the Julia code, one minor version at a time.

If you have just started investigating dynamic linking of Julia, you may find a few things of interest in [GitHub - GunnarFarneback/DynamicallyLoadedEmbedding.jl: Embed Julia with dynamical loading of libjulia at runtime.](https://github.com/GunnarFarneback/DynamicallyLoadedEmbedding.jl)

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [January 24, 2022, 4:59pm UTC](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133/3 "2022-01-24T16:59:04Z")

</div>

Also, I would highly recommend using at least Julia 1.6 (or preferably 1.7) instead of 1.0. The transition from 1.0 to 1.6/1.7 should be pretty much effortless, and the newer Julia versions are significantly better (much lower latency, often faster performance).

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [January 24, 2022, 5:23pm UTC](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133/4 "2022-01-24T17:23:47Z")

</div>

Would it be possible to port the old code to a newer Julia version? Post 1.0, the Julia language and API is quite stable, especially with the help of Compat.jl.

Perhaps it might be useful to tell us what kind of issues you are running into with the old code?

---

<div class="post-metadata">

### Author: ![cariocecus](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@cariocecus](https://discourse.julialang.org/u/cariocecus)
#### Post date: [January 25, 2022, 11:04am UTC](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133/5 "2022-01-25T11:04:28Z")

</div>

Thanks a lot for your replies!

The C application needs to be able to run both codes at the same time, so it seems that the wisest approach is to upgrade both codes to the same version of Julia as you suggest.

---

<div class="post-metadata">

### Author: ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)
#### Post date: [January 25, 2022, 11:29am UTC](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133/6 "2022-01-25T11:29:41Z")

</div>

Use Julia version 0.7 for porting the old code to the new version. There are useful depreciation warnings which you can change to errors with command line flag.

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [January 25, 2022, 11:38am UTC](https://discourse.julialang.org/t/embedding-multiple-versions-of-julia-in-a-single-c-application/75133/7 "2022-01-25T11:38:13Z")

</div>

Eh, no. Julia 0.7 will not be particularly helpful with 0.3 code.

The way to upgrade is to first run it with 0.3 and fix any deprecation warnings if necessary, then repeat the process with 0.4, 0.5, 0.6 and finally 0.7. After that it should run on all 1.x versions.
