Embedding multiple versions of Julia in a single C application

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 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

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.

3 Likes

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).

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?

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.

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.

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.

3 Likes