I have a dynamic library with a function in it that I’d like to call using @threadcall
in Julia 1.3. This doesn’t seem to be possible. Here is a minimal example to reproduce the problem.
/* foo.c */
#include <stdio.h>
void myfunction(int x) {
printf("x is %d\n", x);
}
clang -shared -undefined dynamic_lookup -o libfoo.so foo.c
# foo.jl
using Libdl
lib = dlopen("libfoo.so")
myfunction = dlsym(lib, "myfunction")
ccall(myfunction, Cvoid, (Cint, ), 42) # prints "x is 42"
@threadcall(myfunction, Cvoid, (Cint, ), 42) # causes julia to exit
What am I doing wrong?