Re: [julia-users] Embed julia in C/C++

2014-09-09 Thread Einar Otnes
I have now tried to go back to the basic example in the documentation by calling a single valued function sigmoid from module NumericFuns using jl_eval_string with no success. The code snippet below calling Base.sqrt(2.0) works as anticipated, but the snippet calling NumericFuns.sigmoid(0.0) ends

Re: [julia-users] Embed julia in C/C++

2014-09-09 Thread Einar Otnes
It seems that your suggestion using ccall from within julia to play around with the c-api provides some info. Running your ccall command on a couple of External Packages, i.e. DSP and HDF5 returns the Null pointer. pkg_ptr = ccall(:jl_eval_string,Ptr{Void},(Ptr{Cchar},),DSP.Pkg.hanning)

Re: [julia-users] Embed julia in C/C++

2014-09-09 Thread Isaiah Norton
julia cval(x) = ccall(:jl_eval_string, Ptr{Void}, (Ptr{Cchar},), x) cval (generic function with 1 method) julia cval(using DSP) Ptr{Void} @0x034bc280 julia cval(DSP.hanning) Ptr{Void} @0x306408a0 julia hanning = unsafe_pointer_to_objref(ptr) hanning (generic function with 1

Re: [julia-users] Embed julia in C/C++

2014-09-09 Thread Einar Otnes
Isaiah, Thank you so much for this. This really help and hopefully I can move on making some progress... Einar On Tue, Sep 9, 2014 at 4:06 PM, Isaiah Norton isaiah.nor...@gmail.com wrote: julia cval(x) = ccall(:jl_eval_string, Ptr{Void}, (Ptr{Cchar},), x) cval (generic function with 1

Re: [julia-users] Embed julia in C/C++

2014-09-05 Thread Einar Otnes
Sorry, I'm a bit slow. How do I look up a binding for a specific module? In other words, how would I explicitly get to call the fftfreq function in the DSP module from C/C++? Is this this documented anywhere in Julia docs? Thanks, Einar On Wednesday, September 3, 2014 3:10:59 PM UTC+2,

Re: [julia-users] Embed julia in C/C++

2014-09-05 Thread Ivar Nesje
Sorry, the function is obviously called jl_symbol, not jl_sym On Friday, September 5, 2014 11:15:16 AM UTC+2, Ivar Nesje wrote: I would guess that something like module = jl_eval_global_var https://github.com/JuliaLang/julia/blob/6277015ee3d46f20149136d092525bec95b6e29d/src/julia.h#L917

Re: [julia-users] Embed julia in C/C++

2014-09-05 Thread Ivar Nesje
I would guess that something like module = jl_eval_global_var https://github.com/JuliaLang/julia/blob/6277015ee3d46f20149136d092525bec95b6e29d/src/julia.h#L917 (jl_main_module, jl_sym https://github.com/JuliaLang/julia/blob/6277015ee3d46f20149136d092525bec95b6e29d/src/julia.h#L666 (MyModule))

Re: [julia-users] Embed julia in C/C++

2014-09-05 Thread Einar Otnes
Thank you for your help on this. It seems that the 'jl_eval_global_var' function is local as I got the error undefined reference to `jl_eval_global_var' when linking. I replaced your suggestion with: jl_module_t* jl_dsp_module = (jl_module_t*) jl_get_binding(jl_main_module, jl_symbol(DSP));

Re: [julia-users] Embed julia in C/C++

2014-09-05 Thread Jake Bolewski
It's jl_eval_string located in jl_api.c in src. so you would do jl_value_t * func2 = jl_eval_string(DSP.hanning) The best way to play around with Julia's c-api is within julia itself. julia pkg_ptr = ccall(:jl_eval_string, Ptr{Void}, (Ptr{Cchar},), Base.Pkg.clone) Ptr{Void} @0x7fd11c1754a0

Re: [julia-users] Embed julia in C/C++

2014-09-05 Thread Tobias Knopp
Yes, Jakes suggestion looks good. When I wrote the embedding doku I also played around with several internal functions and it turned out that jl_eval_string is very versatile and can be used in various circumstances. Einar: Would be great if you could test it and improve the embedding

Re: [julia-users] Embed julia in C/C++

2014-09-05 Thread Einar Otnes
I'm happy to help out. Einar On Fri, Sep 5, 2014 at 7:23 PM, Tobias Knopp tobias.kn...@googlemail.com wrote: Yes, Jakes suggestion looks good. When I wrote the embedding doku I also played around with several internal functions and it turned out that jl_eval_string is very versatile and

[julia-users] Embed julia in C/C++

2014-09-03 Thread Einar Otnes
Dear experts, I've looking at the documentation Embedding Julia (http://julia.readthedocs.org/en/latest/manual/embedding/) to figure out how I can call my own julia functions from within C, and I'm struggling to figure out how I should define the jl_module_t that corresponds the module I've