Clang.jl large library

mopg
Fri, 19 Jan 2018 21:19:13 +0000
General Usage

I am trying to link Julia to a large C library. I was thinking that that wouldn’t be an issue given that everyone always says it is straightforward to link C to Julia with minimal performance loss. My problem is that I have never linked different programming languages together, so I am a bit confused by the whole process.

On someone’s recommendation, I started using Clang.jl, but the documentation for that only treats very simple examples (and is not always up-to-date). Clang.jl seems to be exactly what I am looking for, but I’m just struggling how to use it.

Now this is what I have so far (it renders a lot of deprecated warnings, but this is what was in the documentation):

top = cindex.parse_header("<path to .h header file from C library>")

context = wrap_c.init(; output_file="<packagename>.jl", header_library=x->"<packagename>", common_file="<packagename>_h.jl", clang_diagnostics=true)

wrap_c.wrap_c_headers(context, ["<path to .h header file from C library>"])

This generates the <packagename>.jl and <packagename>_h.jl. Now 3 questions:

1. Is this at all a correct way to go about this? The library has a bunch of header files in its include directory, but I am only using the one that you would use if included it from C. The library also has an .so file but I am not doing anything with that.

2. I get the following error, how do I fix that? The documentation talks about it, but that is incomprehensible to me.
/usr/include/stdio.h:33:11 fatal error: 'stddef.h' file not found

3. What am I supposed to do with the <packagename>.jl and <packagename>_h.jl files once they are generated? Does including them give me access to the C library?

Sorry for the very basic questions, any help is much appreciated.

9 posts - 3 participants