Hello,
I’m trying to import a local Julia module from C and call a function;
but jl_get_function always return a null pointer.
I based my code on this topic and this SO question, but nothing I’ve tried worked.
This is the C-code :
/* required: setup the Julia context */
jl_init();
{
printf("include test.jl \n");
jl_eval_string("Base.include(Main, \"./test.jl\")");
// Tried both version with no success
// jl_eval_string("include(\"./test.jl\")");
printf("using custom_module \n");
jl_eval_string("using custom_module");
{
printf("dummy \n");
// Call easy function
jl_function_t *dummy= jl_get_function(jl_main_module, "dummy");
if (dummy != NULL)
{
printf("dummy is not null\n");
}
else
{
printf("dummy is null\n");
jl_atexit_hook(0);
return 0;
}
jl_call0(dummy);
jl_atexit_hook(0);
return 0;
}
This the julia file:
module custom_module
using LinearAlgebra
function dummy()
println("Hello world from dummy")
end
function testMeBaby(A)
println(typeof(A))
println(A)
B = lmul!(10, A)
println(B)
println(size(B))
println(ndims(B))
return B
end
export testMeBaby
export dummy
end
What am I missing or doing wrong here ?
I’m using gcc 9.3.0 &nd Julia v1.4.2 with Ubuntu 20.04 inside WSL2.
Also Is there any restriction I should be aware of when executing Julia function from C ?