I am trying to call Julia from C++ shared library. From the log, it seems
the call to jl_eval_string("sqrt(2.0)") return correct value.
The problem is that the function CPPCallJulia::gssqrt( ) never return to
caller ( If I remove Julia function, it works fine).
g++ -c -W -O3 -m64 -fPIC CPPCallJulia.cpp -I$JULIA_DIR/include/julia
g++ -O3 -shared -m64 -WI -fPIC -o./libCPPCallJulia.so CPPCallJulia.o
-L$JULIA_DIR/lib/julia -lm -ljulia
Thanks for the help.
Jason
string CPPCallJulia::gssqrt(const vector<string> & args)
{
ofstream f("/home/ju_log.txt",ios::out);
stringstream s;
double result=1000;
jl_init("/home/Julia/julia-2e358ce975/bin");
jl_value_t *ret = (jl_value_t*)jl_eval_string("sqrt(2.0)");
if (jl_is_float64(ret)) {
result = jl_unbox_float64(ret);
}
jl_atexit_hook(0);
s << result;
if(f.is_open()){
f<<"=== result ";
f<<s.str();
f.close();
}
return s.str();
}