Hi
I am trying to use the julia C interface in orger to call Julia from within my C++ program.
I would like to save some plots but it does not seems to work.
Here is a snapshot of the code i used so far:
{
// here used jl_main_module not like in the Julia's Doc !
jl_function_t *pl_sim = jl_get_function(jl_main_module, "plot_model_sim");
jl_function_t *pl_data = jl_get_function(jl_main_module, "plot_model_data");
jl_module_t* PLOTS = (jl_module_t *)jl_eval_string("Plots");
jl_function_t *save = jl_get_function(PLOTS, "savefig");
std::cout << "\n julia: found functions? " << save << ":" << pl_sim << ":" << pl_data << std::endl;
jl_value_t *a1 = jl_box_float64(params[0]);
jl_value_t *a2 = jl_box_float64(params[1]);
jl_value_t *a3 = jl_box_float64(params[2]);
jl_value_t *a4 = jl_box_float64(params[3]);
jl_value_t *a5 = jl_box_float64(params[4]);
jl_value_t *args[5] = {a1 , a2, a3, a4, a5};
jl_value_t *plt_data = jl_call(pl_data, args, 5);
//jl_eval_string("savefig(\"model_data.png\")");
jl_value_t *plt_sim = jl_call(pl_sim, args, 5);
JL_GC_PUSH1(&plt_sim);
//jl_eval_string("savefig(\"model_sim.png\")");
jl_value_t *title = jl_eval_string(" \"output.png\" ");
jl_value_t *out = jl_call2(save, plt_sim, title);
std::cout << "\n julia: outputs diagnostics " << std::endl;
JL_GC_POP();
};
the call to savefig crashed with the output attached here.