# Guidelines for wrapping a simple C library in Julia

**URL:** <https://discourse.julialang.org/t/guidelines-for-wrapping-a-simple-c-library-in-julia/112335>\
**Category:** General Usage\
**Tags:** ccall, binarybuilder, c, clang\
**Created:** [March 30, 2024, 8:13pm UTC](https://discourse.julialang.org/t/guidelines-for-wrapping-a-simple-c-library-in-julia/112335 "2024-03-30T20:13:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [March 30, 2024, 8:33pm UTC](https://discourse.julialang.org/t/guidelines-for-wrapping-a-simple-c-library-in-julia/112335/2 "2024-03-30T20:33:11Z")

</div>

May be you first start with learning how to call C code - you can call it directly from julia via `ccall`, and you can load your locally built library into Julia via `dlopen`, see [Calling C and Fortran Code · The Julia Language](https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/) . If your API is small, you can easily write Julia wrappers invoking `ccall` by hand. CBinding.jl tries to automate this process.

The BinaryBuilder allows to maintain precompiled libraries and wrap them into jll packages. You would use this to distribute the precompiled C code to users of your Julia library.

That said, did you consider to implement your algorithm directly in Julia ? It could be more flexible with respect to data types, and a nice learning exercise.

---

_[View the full topic](https://discourse.julialang.org/t/guidelines-for-wrapping-a-simple-c-library-in-julia/112335)._
