I’m having some trouble including a file from the C api (via Java - but hopefully that doesn’t matter)
My code is:
#include <jni.h>
#include <stdio.h>
#include <julia.h>
void REPT() {
if (jl_exception_occurred()) {
jl_call2(
jl_get_function(jl_base_module, "show"),
jl_stderr_obj(),
jl_exception_occurred());
jl_printf(jl_stderr_stream(), "\n");
} else {
printf("OK\n");
}
}
extern "C" JNIEXPORT jint JNICALL sayHello
(JNIEnv * env, jobject self) {
jl_init();
REPT();
printf("Printing include...\n");
jl_eval_string("print(include)");
REPT();
jl_eval_string("include(\"code.jl\")");
REPT();
jl_atexit_hook(0);
}
and it is outputting :
OK
Printing include...
UndefVarError(:include)
UndefVarError(:include)
This suggests to me that the include function is not getting setup for some reason.
In contrast if I do a print(include)
from the julia REPL I get Base.MainInclude.include
as I’d expect.
What am I doing wrong?