I’m more a C++ developer than Julia dev but years ago I made a pure Julia project and successfully deployed it on the official Julia packages. This time, I made a pure C++ project (let’s name it
MyProject) for a standalone graphical application and now I want to create a
MyProject.jl project to bind it.
The build system of the C++
MyProject also compiles and install a shared library exporting some C++ API. In this C++ project I also have Julia bindings on this shared library. From the Julia REPL, I can load the lib, call my Julia binding and run my graphical application. Everything works perfectly.
Here is a simple overview of the tree of my C++ project:
MyProject/src/*.[ch]pp <-- Code source of my application MyProject/src/julia/bindings.[ch]pp <-- Bind my C++ API to C for being used with Julia's ccall() MyProject/src/julia/MyProject.jl <-- Julia functions calling ccall()
MyProject.jl Julia file is not a module (does not have
module MyProject export ... end). Therefore inside the REPL I have to do:
The code is like:
const my_lib = "/usr/lib/libmyproject.so" function foo_bar() FooBar(ccall((:foobar, my_lib), Clonglong, ())) end
I tried to read the code of project such as Gtk.jl but I did not get the point on how they manage the lib path depending on the operating system:
grep -rnHe "libgtk3" src/Gtk.jl:14:const libgtk = libgtk3 grep -rnHe "dll" gen/gtk_consts_gen.jl:6: "G_MODULE_SUFFIX" => :(Sys.iswindows() ? "dll" : "so"), #For "most" Unices and Linux this is "so".
Since my project is not a mainstream (yet ^^) project such as gtk+, therefore people does not have my shared library installed on their operating system. Therefore I’m looking how to create a pure Julia project binding my C++ project. What is the good way for:
- Organizing folders of MyProject.jl ? For example can I use git submodules to include my C++ MyProject ? is Julia package manager deals (the
]) with git submodules ?
- Have I to compile my C++ project from MyProject.jl or can I give directly the .so, .dll, .dylib shared libraries inside the project ?
- How to search correctly the shared library.
- My project depends on external system libraries (i.e. libsfml.so) shall the user has to install these libraries ?
- When the user do a
] add MyProjecthow to tell to Julia clone with submodules and compile the project ?
Is something like can work ?
MyProject.jl/Project.toml MyProject.jl/src/MyProject.jl <-- Julia module + exporting functions calling ccall() MyProject.jl/thirdpart/MyProject/src/*.[ch]pp <-- Code source of my git submodules C++ project MyProject.jl/thirdpart/MyProject/src/julia/bindings.[ch]pp <-- Bind my C++ API to C for being used with Julia's ccall() MyProject.jl/thirdpart/MyProject/src/julia/MyProject.jl <-- Julia functions calling ccall() without module keyword (maybe to be renamed)
And the code of MyProject.jl/src/MyProject.jl
module MyProject include("thirdpart/MyProject/src/julia/MyProject.jl") export ... end
Thank you !