# Using JuliaC from R/Python?

**URL:** <https://discourse.julialang.org/t/using-juliac-from-r-python/132857>\
**Category:** General Usage\
**Tags:** juliac\
**Created:** [October 3, 2025, 4:30pm UTC](https://discourse.julialang.org/t/using-juliac-from-r-python/132857 "2025-10-03T16:30:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![biona001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/biona001/32/16497_2.png) [@biona001](https://discourse.julialang.org/u/biona001)\
**Post date:** [October 3, 2025, 4:30pm UTC](https://discourse.julialang.org/t/using-juliac-from-r-python/132857/1 "2025-10-03T16:30:31Z")

</div>

Hi,

Now that [JuliaC.jl](https://github.com/JuliaLang/JuliaC.jl) is released, I want to try something I’ve always wanted: being able to pass a matrix from R into Julia, have it do something, then returning a scalar/vector/matrix back into R. I’m thinking of compiling 2-3 different julia apps (one for each OS) and have them be part of my Rpackage directly.

Has anyone done this before? Just wanted to see if there’s some examples before I get into the weeds.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 3, 2025, 5:28pm UTC](https://discourse.julialang.org/t/using-juliac-from-r-python/132857/2 "2025-10-03T17:28:21Z")

</div>

Idk how R calling a shared library works but yeah it’s definitely doable, here’s an example from python [FHist.jl/C\_FHist/jlsum.py at C\_FHist · Moelf/FHist.jl · GitHub](https://github.com/Moelf/FHist.jl/blob/C_FHist/C_FHist/jlsum.py)

---

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [October 3, 2025, 7:27pm UTC](https://discourse.julialang.org/t/using-juliac-from-r-python/132857/3 "2025-10-03T19:27:43Z")

</div>

For R you probably want to consider the .Call interface from R (see the R manual “Writing R Extensions” for details). In .Call all the arguments to a C-callable function in a shared library are pointers to symbolic expressions (SEXPREC) which is the basic internal object type in R. The return value from such a function is also a pointer (SEXP) to a SEXPREC.

The code for boxing/unboxing SEXPRECs from the Julia side is currently part of the RCall package. If using JuliaC to created shared libraries of R callable functions becomes popular it may be worthwhile separating the boxing/unboxing code into its own Julia package.

---

<div class="post-metadata">

**Author:** ![biona001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/biona001/32/16497_2.png) [@biona001](https://discourse.julialang.org/u/biona001)\
**Post date:** [October 3, 2025, 7:58pm UTC](https://discourse.julialang.org/t/using-juliac-from-r-python/132857/4 "2025-10-03T19:58:50Z")

</div>

Oh if only there is a legendary figure who knew both the dark magic of R’s internals _and_ the light of Julia’s macros! If such a person existed… surely they will descend from the mountains and show us mortals how to tame the SEXPs and make them obey Julia’s will 🙏

If only!

---

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [October 3, 2025, 9:06pm UTC](https://discourse.julialang.org/t/using-juliac-from-r-python/132857/5 "2025-10-03T21:06:57Z")

</div>

Even though I was part of R Core for twenty years it was when I started work on RCall.jl (I just started it, the majority of the development and enhancement was done by Simon and Randy) that I really began to understand the internals of R, because I could use Julia to pick apart those structures. One of the beautiful aspects of Julia is that you have so much power and flexibility available to you in a REPL.

---

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [October 11, 2025, 6:07pm UTC](https://discourse.julialang.org/t/using-juliac-from-r-python/132857/6 "2025-10-11T18:07:30Z")

</div>

I added a comment in [Using rcopy and sexp methods to create a .Call interface to a compiled Julia library · Issue #556 · JuliaInterop/RCall.jl · GitHub](https://github.com/JuliaInterop/RCall.jl/issues/556) with a proof-of-concept for loading a shared library created by juliac into an R session and calling a Julia function from R.

This example uses the more basic .C interface from R, not the .Call or .External interface. I think it should be possible to extract the code defining methods for `rcopy` and `sexp` from the `RCall.jl` package into a separate package, say `RObjects.jl`, so that that code can be used in both `RCall.jl` and in code that will be compiled to a shared library to be called from R.

By the way, please comment in that issue if there are better ways of calling `juliac`, etc. for this usage. As I said, this is a proof-of-concept at this stage, not a demonstration that I know what I’m doing.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 11, 2025, 6:46pm UTC](https://discourse.julialang.org/t/using-juliac-from-r-python/132857/7 "2025-10-11T18:46:51Z")

</div>

Note you can already call Julia from R (and e.g. Python), independently of juliac (you can compile in many ways or just skip doing that; C in juliac means compiler not the C language, though in some sense it will also compile Julia code to “C API” usable code):

> [@Bindings/wrappers for Julia packages, how many? From which languages?](https://discourse.julialang.org/t/bindings-wrappers-for-julia-packages-how-many-from-which-languages/132967):
>
> Continuing the discussion from [Wrap Julia package in Python: which is the best option?](https://discourse.julialang.org/t/wrap-julia-package-in-python-which-is-the-best-option/79344): When you wrap a Julia package, as in 2. or 3., yes it’s a wrapper, but also called a binding, when used from another language like Python or R. I’ve used the former word more, but trying to use the technically correct latter word myself (the former needs not be across languages). Those are the two main binding packages I recall (and JuliaCall used for both, pyjulia before, and I believe JuliaCall best to u…

> [@biona001](#):
>
> I’m thinking of compiling 2-3 different julia apps

It seem you mean you want Julia libraries, to call from e.g. an R app? JuliaC can compile apps, yes, but also libraries I understand, and you want the latter? You will not call or “use” juliac from the other languages (so I would clarify the title here), only using once to make a dynamic-link library, and then you can call that library from your other language as easily as calling C.

You don’t need juliac, just to call, e.g. pass a matrix, it’s just if you want a smaller binary (dropping most of the Julia runtime). It seemingly shouldn’t be too hard just even easier with juliacall.

Note the juliacall for Python is very smooth, will download Julia for you, but the juliacall for R is I think more manual (still, could be improved), and note this:

> <https://github.com/JuliaInterop/JuliaCall/issues/263>
>
> My operating system is Ubuntu 24.04.
> 
> To ensure I had the most recent version of… the R package “JuliaCall”, I installed “JuliaCall” from github as follows:
> 
> devtools::install\_github(“JuliaInterop/JuliaCall”)
> 
> The problem is that running julia\_setup() produces a segmentation fault. For example:
> 
> library(JuliaCall)
> julia\_setup(rebuild=TRUE)
> Julia version 1.11.6 at location /home/robert/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/bin will be used.
> Loading setup script for JuliaCall…
> Finish loading setup script for JuliaCall.
> Segmentation fault (core dumped)
> 
> Any help is much appreciated!

You can use it but you will avoid that issue by using juliac yes. If you just want to use Julia from other languages, as easily as possible (and don’t care from which; first), I would start with from Python, and then you could use juliac after that is working. [You can also use Julia as the main language, with or without compiling a julia app (using e.g. juliac, not the only option to compile!), including to call the other languages, one or even both/any, but didn’t seem what you were after.]

You can have some C library callable from R, I assume easy, you can also have the same library callable from Python, and also if you compile Julia code into a library, it will look more or less like a C library or dynamic link library, so as easy. What I’m not 100% sure if is what are the redundant steps you need for Python vs R, i.e. if some needed, or even if some, or all, can be automated, to make easier to call from both of the languages. I think R is usually calling C++ code, but more common to call C code from Python, then will be more different I think, but I think you can just as easily call C (then also Julia) from R, since C is a (non-strict) subset of C++.

> **[GitHub - TheCedarPrince/InteroperableJuliaBinaries: Experiments in making Julia binaries interoperable...](https://github.com/TheCedarPrince/InteroperableJuliaBinaries#running-from-within-r)**
>
> Experiments in making Julia binaries interoperable within other language C interfaces.

> [@dmbates](#):
>
> I added a comment in [Using rcopy and sexp methods to create a .Call interface to a compiled Julia library · Issue #556 · JuliaInterop/RCall.jl · GitHub](https://github.com/JuliaInterop/RCall.jl/issues/556) with a proof-of-concept for loading a shared library created by juliac into an R session and calling a Julia function from R.

Great! I see a comment from 1 hour ago, and you opened that issue on Feb 27. RCall.jl is well of course for calling R, and its readme has:

> ## Calling Julia from R
> 
> ### See the JuliaCall library to call Julia from R.

But the link to it is failing, I believe it moved, others took over, and needs to point to that… i.e. to [GitHub - JuliaInterop/JuliaCall: Embed Julia in R](https://github.com/JuliaInterop/JuliaCall) and/or to [CRAN: Package JuliaCall](https://cran.r-project.org/web/packages/JuliaCall/index.html) since the former is only almost up-to-date, NEWS at both places have the important 1.17.6 patch release (fixing breakage in Julia), but it’s not under releases at former, for some reason only 1.17.5 so what do you get if installing?

---

<div class="post-metadata">

**Author:** ![biona001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/biona001/32/16497_2.png) [@biona001](https://discourse.julialang.org/u/biona001)\
**Post date:** [October 12, 2025, 3:23am UTC](https://discourse.julialang.org/t/using-juliac-from-r-python/132857/8 "2025-10-12T03:23:50Z")

</div>

You are the hero we all need but don’t deserve!
