I am testing PackageCompiler with the examples in the repo. I am able to compile the library correctly following the documentation but then when I try to use it in Python with the following code I just get
Debugging it, basically it crashes when calling the increment method.
Wondering if anyone could point me to debug what is going on.
Many thanks,
Eduard
import ctypes
import os
from ctypes import c_void_p, RTLD_GLOBAL
libjulia = ctypes.CDLL('MyLibCompiled/lib/libjulia.so', RTLD_GLOBAL)
libjulia.jl_init()
however when doing jl_init() I get
ERROR: could not load library "MyLibCompiled/lib/../bin/../lib/julia/sys.so"
MyLibCompiled/lib/../bin/../lib/julia/sys.so: cannot open shared object file: No such file or directory
As the path is trimmed I cant really know what is happening but it seems is trying to find this file but it didnt get ocmpiled?
Thanks again Mark! I would prefer to avoid using juliacall as I plan to call from other languages such as java. I found a libcg repo which successfully build and calls a librar From c and rust however i read that there are some libraries that don’t work well and that everything needs to be statically typed which limits the usage quite a bit
This is slightly easier to describe from either C or Zig than Python.
You can see the julia_init function the libcg function that libcg uses works:
Basically, we need to communicate to Julia the location of the system image. You can either populate the jl_options struct directly or use the command line option processor. The -J or --sysimage command line option indicates the system image location.
As I say this though, I suspect that the juliac tool is about to be reincarnated, which might provide a whole new pathway to do this.
The bottom line is that you must initialize the Julia runtime before invoking that C pointer.