How to distribute a wrapper for a C++ library?

Could anyone share experience on how to distribute a C++ wrapper through package manager?

My workflow idea is the following:

  • package is available from a third-party registry
  • wrapped library and C++ shim are packaged in binary form and available from the same registry

Given that the shim depends on the wrapped library and the Julia module needs to load the shim first to work, what would be the recommended way to specify the paths to the corresponding artifacts?

I think you want to create a JLL package – GitHub - JuliaPackaging/Yggdrasil: Collection of builder repositories for BinaryBuilder.jl is probably the way to go.

1 Like

Yes, I think so too but so far I don’t have experience with that.
Say, I’ve managed to build a JLL for a binary library.
Now, how should I get the path to the .so file associated with it? Would it be exported in JLL or maybe it’s going to be a fixed path relative to JULIA_DEPOT_PATH?

It’s a good practice to follow hello world samples,

for C:

C++:

FORTRAN:

GO:

OCaml:

Rust:

2 Likes

Let’s have a look at a JLL package.

julia> using OpenSlide_jll

julia> names(OpenSlide_jll)
2-element Vector{Symbol}:
 :OpenSlide_jll
 :libopenslide

julia> OpenSlide_jll.libopenslide
"/home/gunnar/.julia/artifacts/e6604bff9ad493834da0c27adf8174616d54864e/lib/libopenslide.so"
1 Like

Thank you all for the directions!
Now I have to dig deeper into the BinaryBuilder and JLLs.

For example, QML.jl uses CxxWrap.jl to provide C-callable wrappers for an external C++ library (Qt). It seems to compile the wrapper and the C++ library into a single library: GitHub - JuliaGraphics/jlqml: C++ component of the QML.jl package, which packages a library in Julia as jlqml_jll using this Yggdrasil build script.

I was thinking too if it would be logical to package both wrapper and the original library into a single JLL. Thanks for pointing to a way how it may be done!