Ccall with return vector<double>

question

#1

Hello, I have a function in a shared library (self-written) where I have a vector<double> as a return type. Now, how would I organize the ccall in order to get a `Array{Float64} in Julia.

I cannot figure it out on my own. Any help would be great. Thanks.

I tried:

ccall((:func_name, "path/to/file.so"), Ptr{Cdouble}, ())

But thid does not work and troughs a SegFault.


#2

vector<double> is a C++ type, so presumably you’re wrapping a C++ library, not a C library. Ccall only works for C libraries, which is why you’re having problems. You’ll need to either write a C-compatible wrapper for your C++ library or use https://github.com/Keno/Cxx.jl


#3

Or CxxWrap: