I’m wrapping libwebsockets in Julia for better integration and performance. Unfortunately, I didn’t find it in JuliaBinaryWrappers. After that i want to introduce simpler analogue for HTTP.jl based on this c lib (previously i tried libcurl, however, there is no websocket support). Do you have any advices? This is my first time wrapping lib myself (before that I used libCurl_jll)
I’m sure that the right thing to do is to use something like Clang.jl to generate the wrapper for you. I don’t know much about it, even though I have drug my eyes over the documentation a few times.
If you are mildly masochistic, you can write Julia analogs of the structures used, and call all of the library functions from Julia using @ccall
. I have a semi-large-ish C++ library that I have wrapped that way. I don’t have any experience with libwebsockets
, but it looks semi-large. Probably large enough to make fussing around with Clang worthwhile.
Here is my example code (in this Discourse link). Since you are wrapping C, you wouldn’t need to have a C library wrapper layer. I do recommend that you get bindings autogenerated, rather than doing it manually though.
And what about BinaryBuilder? Or is this previous stage before using Clang.jl to generate wrapper?
You may be right - I haven’t successfully used Clang.jl before.
Also, have you seen: GitHub - JuliaWeb/WebSockets.jl: A WebSockets library for Julia?
Both are kind of necessary steps. I prefer doing the binarybuilder one first because it tends to make the following steps a lot easier though nothing stops you from building the wrapper with a local build.
Any news @DeevsDeevs ?
I noticed GitHub - maxfadson/libwebsockets_jll.jl and GitHub - JuliaBinaryWrappers/libwebsockets_jll.jl are now available.
I published a project skeleton for LibWebsockets.jl https://github.com/femtotrader/LibWebsockets.jl
$ cd gen/
$ julia --project=. generator.jl
can generate code in lib/wrapper.jl
but I’m still locked trying to compile it using
cd ..
julia --project=. test/runtests.jl
with the following error
ERROR: LoadError: UndefVarError: lws_plat_file_ops
not defined in LibWebsockets.LibWebsocketsWrapper
Feel free to look at it, fork and improve code.
Maybe you had an old version of the code loaded? For me the package loads and the tests pass.
is now released.
That’s not my code (mine is now still available at GitHub - femtotrader/WIP_LibWebsockets.jl: Julia wrapper for https://libwebsockets.org/). Thanks bhft guys for their contribution to open source.
my personal advice: just don’t use julia for anything web / trading related