# Wrapping libwebsockets C Library with Julia

**URL:** <https://discourse.julialang.org/t/wrapping-libwebsockets-c-library-with-julia/102959>\
**Category:** Web Stack\
**Created:** [August 18, 2023, 4:44pm UTC](https://discourse.julialang.org/t/wrapping-libwebsockets-c-library-with-julia/102959 "2023-08-18T16:44:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![frylock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frylock/32/50213_2.png) [@frylock](https://discourse.julialang.org/u/frylock)\
**Post date:** [August 18, 2023, 5:13pm UTC](https://discourse.julialang.org/t/wrapping-libwebsockets-c-library-with-julia/102959/2 "2023-08-18T17:13:25Z")

</div>

I’m sure that the _right_ thing to do is to use something like [Clang.jl](https://github.com/JuliaInterop/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](https://discourse.julialang.org/t/advice-for-wrapping-c-library-that-throws-exceptions/101855)). 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.

---

_[View the full topic](https://discourse.julialang.org/t/wrapping-libwebsockets-c-library-with-julia/102959)._
