Skip to main content

jlbind jlbind logojlbind logo

Call Julia code from R without starting a Julia session.

jlbind compiles Julia code into a shared library with JuliaC.jl (by default with --trim=safe), and R calls it through R’s official C API. Thus, there is almost no overhead (see Performance).

Several R packages using jlbind can be installed side by side: their Julia code is compiled into one shared library.

Installation

# install.packages("pak")
pak::pak("BjarkeHautop/jlbind")

Building the shared library requires Julia >= 1.13. Installing jlbind does not itself build the library.

Julia 1.14 or later is recommended: Julia 1.13 can compile a library that crashes as it loads when a function has a type parameter bounded by a Union (where {T<:Union{...}}), fixed in JuliaLang/julia#63664.

Using a package built on jlbind

After installing or updating an R package that uses jlbind, build the shared library:

jlbind::install_library()

This compiles the Julia code of every installed package that uses jlbind and may take a few minutes. Run it again whenever you install or update one of them.

See Using packages built on jlbind for threads, troubleshooting and Julia dependency versions.

Writing a package that uses jlbind

Set up a package with jlbind::use_jlbind(), then declare the Julia functions R can call in the generated binding package under inst/julia/:

module MyPkgBindings

using JLBind

greet(name::String) = "Hello, " * name * "!"
@rcall greet(name::String)::String

end

Run jlbind::update_entrypoints(), which generates the R function greet(name) that calls it.

See Get started with jlbind for a full walkthrough.

Contributing

Contributions of all kinds are very welcome! You may use LLMs, but please write issue and PR descriptions in your own words. If you submit a PR, you should understand the code you’re contributing.

License

MIT + file LICENSE

Citation

Citing jlbind

Developers

Bjarke Hautop Kristensen
Author, maintainer

Dev status

R-CMD-check Codecov test coverage