what is the best way to create a julia function wrapper of a C++ function. I started with the Cxx package and just put the C++ code in cxx""" but it is quite slow. Now I´m considering to use the CxxWrap package. Is it the currently method, which leads to the best performance of embedding C++ code to julia? Or is there something else what is better?
It depends on your specific use case. If you’re wrapping a small cpp library which only exports a few APIs or a large one in which you only need to call a small subset API, then the “best way” would be to manually 1. write a C89 wrapper over the library and 2. embed it in Julia by directly using ccall. No package, no magic, and no performance overhead. However, if you’re gonna wrap everything in a large cpp library, it is just not feasible to manually do the above two steps.
Currently, there are three packages that try to alleviate the pain point of manually doing these boring jobs:
I tried to follow your advise (explained in the quote). I found this little example https://perfectionatic.org/?p=249 and followed the instructions. I can also build the library but when I use the command
using Libdl
push!(Libdl.DL_LOAD_PATH,"C:/Users/xxx/Downloads/lib_mean/src/libmean.so")
x=ccall((:mean,"libmean"),Float64,(Float64,Float64),2.0,5.0)
println(x)
I got an error "error compiling top-level scope: could not load library “libmean” "
Do you know what I have done wrong? I´m working on Windows 10, Julia 1.1.0