Doubt about using Clang.jl

I am trying to use to Clang.jl to parse header files for GNUAstro. GNUAstro has a dependency called wcslib. When I try to run the generated .jl file, I get the error that wcsperm is not defined. That makes sense because wcsperm is defined in wcslib header files not in GNUAstro. My question is how to fix this issue. In general, how to utilise structs and functions from dependencies ?

How did you build GNUAstro? If you use some compiler flags(e.g. -I/path/to/wcslib.h), you also need to pass them to Clang.jl. Specifically,

wc = init(; headers = LIBCLANG_HEADERS,
            output_file = joinpath(@__DIR__, "libclang_api.jl"),
            common_file = joinpath(@__DIR__, "libclang_common.jl"),
            clang_includes = vcat(LIBCLANG_INCLUDE, CLANG_INCLUDE),
            clang_args = ["-I", joinpath(LIBCLANG_INCLUDE, ".."), "-I", "/path/to/wcslib.h"],
            header_wrapped = (root, current)->root == current,
            header_library = x->"libclang",
            clang_diagnostics = true,
            )

Ok, I’ll do that. Another thing, I want to ask is that many library like cfitsio and gsl already have julia wrappers. Is it possible or useful to use them while building this wrapper ?

Here is my code:

using Clang

const LIBCLANG_INCLUDE = joinpath(@__DIR__, "gnuastro") |> normpath
const LIBCLANG_HEADERS = [joinpath(LIBCLANG_INCLUDE, header) for header in readdir(LIBCLANG_INCLUDE) if endswith(header, ".h")]

wc = init(; headers = LIBCLANG_HEADERS,
            output_file = joinpath(@__DIR__, "libgnuastro_api.jl"),
            common_file = joinpath(@__DIR__, "libgnuastro_common.jl"),
            clang_includes = vcat(LIBCLANG_INCLUDE, LIBCLANG_INCLUDE),
            clang_args = ["-I/usr/include", joinpath(LIBCLANG_INCLUDE, "..")],
            header_wrapped = (root, current)->root == current,
            header_library = x->"libgnuastro",
            clang_diagnostics = true,
            )

run(wc)

I am getting the following logs.

warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/box.h:69:44: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/box.h:74:49: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/time.h:29:10: fatal error: 'stddef.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/pointer.h:52:38: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:54:1: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:58:36: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:62:41: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:41: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:51: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:64:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:67:39: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:70:43: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:50: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:74:29: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/qsort.h:135:3: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/sched.h:29:10: fatal error: 'stddef.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/arithmetic.h ...
┌ Warning: Skipping VarArg Function CLCursor (CLFunctionDecl) gal_arithmetic(int, int, int, ...)
â”” @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:15
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/array.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/binary.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/blank.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/box.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/convolve.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/cosmology.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/data.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/dimension.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/eps.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/fits.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/git.h ...
┌ Warning: No Prototype for CLCursor (CLFunctionDecl) gal_git_describe() - assuming no arguments
â”” @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:13
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/interpolate.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/jpeg.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/label.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/list.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/match.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/pdf.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/permutation.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/pointer.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/polygon.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/qsort.h ...
┌ Warning: not wrapping CLCursor (CLVarDecl) gal_qsort_index_single
â”” @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:446
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/speclines.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/statistics.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/table.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/threads.h ...
┌ Warning: No Prototype for CLCursor (CLFunctionDecl) gal_threads_number() - assuming no arguments
â”” @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:13
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/tiff.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/tile.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/txt.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/type.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/units.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/wcs.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl

I think it’s good to keep these wrappers orthogonal to each other. Library B depends on library A means that the implementation of B makes use of some public APIs of A, so only those binaries matter and this binary dependency problem has been solved by BB2. Clang.jl will search wcslib’s header files for certain types that are only defined there and directly map these types to basic Julia types, so there is no need to make GNUAstro depends on wcslib.

1 Like

Understood. Regarding the error log, is it normal or do I need to fix something?

These errors are basically clang errors, which means Clang.jl cannot correctly detect those system headers. For example, /usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found means clang cannot found stdio.h in the path /usr/include/stdio.h.

warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/box.h:69:44: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/box.h:74:49: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/time.h:29:10: fatal error: 'stddef.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/pointer.h:52:38: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:54:1: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:58:36: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:62:41: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:41: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:51: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:64:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:67:39: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:70:43: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:50: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:74:29: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/qsort.h:135:3: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/sched.h:29:10: fatal error: 'stddef.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found

This doesn’t look right to me. It should be clang_args = ["-I/usr/include", "-I", joinpath(LIBCLANG_INCLUDE, "..")], and there is no need to add “-I/usr/include” except you’re working on macOS(in fact, one should use args=["-I", joinpath(LIBCLANG_INCLUDE, ".."), map(x->"-I"*x, find_std_headers())...] on Mojave+).

I am on Ubuntu. I removed /usr/include. Now the line is clang_args = ["-I", joinpath(LIBCLANG_INCLUDE, "..")], . I still get the errors.

/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/home/amcap1712/GNUAstro/gnuastro/box.h:69:44: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/box.h:74:49: error: unknown type name 'size_t'
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/time.h:29:10: fatal error: 'stddef.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/home/amcap1712/GNUAstro/gnuastro/pointer.h:52:38: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:54:1: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:58:36: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:62:41: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:41: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:51: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:64:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:67:39: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:70:43: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:50: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:74:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/qsort.h:135:3: error: unknown type name 'size_t'
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/sched.h:29:10: fatal error: 'stddef.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/arithmetic.h ...
┌ Warning: Skipping VarArg Function CLCursor (CLFunctionDecl) gal_arithmetic(int, int, int, ...)
â”” @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:15
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/array.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/binary.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/blank.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/box.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/convolve.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/cosmology.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/data.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/dimension.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/eps.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/fits.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/git.h ...
┌ Warning: No Prototype for CLCursor (CLFunctionDecl) gal_git_describe() - assuming no arguments
â”” @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:13
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/interpolate.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/jpeg.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/label.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/list.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/match.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/pdf.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/permutation.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/pointer.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/polygon.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/qsort.h ...
┌ Warning: not wrapping CLCursor (CLVarDecl) gal_qsort_index_single
â”” @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:446
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/speclines.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/statistics.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/table.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/threads.h ...
┌ Warning: No Prototype for CLCursor (CLFunctionDecl) gal_threads_number() - assuming no arguments
â”” @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:13
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/tiff.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/tile.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/txt.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/type.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/units.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/wcs.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl

Is /usr/include/limits.h a valid path on your machine?

Yes I am able to view this file in terminal.

That’s strange. I’m going to test it on my machine.

using Clang
using Gnuastro_jll, WCS_jll, GSL_jll, CFITSIO_jll

const CFITSIO_INCLUDE = joinpath(dirname(CFITSIO_jll.libcfitsio_path), "..", "include") |> normpath
const GSL_INCLUDE = joinpath(dirname(GSL_jll.libgsl_path), "..", "include") |> normpath
const WCS_INCLUDE = joinpath(dirname(WCS_jll.libwcs_path), "..", "include") |> normpath
const GNUASTRO_INCLUDE = joinpath(dirname(Gnuastro_jll.libgnuastro_path), "..", "include") |> normpath
const GNUASTRO_HEADERS = [joinpath(GNUASTRO_INCLUDE, "gnuastro", header) for header in readdir(joinpath(GNUASTRO_INCLUDE, "gnuastro")) if endswith(header, ".h")]

wc = init(; headers = GNUASTRO_HEADERS,
            output_file = joinpath(@__DIR__, "libgnuastro_api.jl"),
            common_file = joinpath(@__DIR__, "libgnuastro_common.jl"),
            clang_includes = [GNUASTRO_INCLUDE, CFITSIO_INCLUDE, GSL_INCLUDE, WCS_INCLUDE, CLANG_INCLUDE],
            clang_args = ["-I", joinpath(GNUASTRO_INCLUDE, "gnuastro"),
                          map(x->"-I"*x, find_std_headers())...],
            header_wrapped = (root, current)->root == current,
            header_library = x->"libgnuastro",
            clang_diagnostics = true,
            )

run(wc)

This basically works, except the error: unknown type name 'xxx' error. After some investigation, it looks like Gnuastro did this intentionally, since Clang.jl currently has limitations for supporting multi-platform, you need to patch this yourself.

/* Define system specific types. For example `size_t' is 4 and 8 bytes on
   32 and 64 bit systems respectively. In both cases, the standard defines
   `size_t' to be unsigned. A similar case exists for `long', but it is
   signed. During `./configure' the sizeof `size_t' and `long' were found
   and are used to define an alias for these system specific types.

   Note: we are not using `else'. This is done because by any chance, if
   the length of these types is not what is expected (4 or 8), then the
   aliases are not defined and the compiler will crash. */
#if GAL_CONFIG_SIZEOF_SIZE_T == 4
#define GAL_TYPE_SIZE_T GAL_TYPE_UINT32
#elif GAL_CONFIG_SIZEOF_SIZE_T == 8
#define GAL_TYPE_SIZE_T GAL_TYPE_UINT64
#endif

#if GAL_CONFIG_SIZEOF_LONG == 4
#define GAL_TYPE_LONG  GAL_TYPE_INT32
#define GAL_TYPE_ULONG GAL_TYPE_UINT32
#elif GAL_CONFIG_SIZEOF_LONG == 8
#define GAL_TYPE_LONG  GAL_TYPE_INT64
#define GAL_TYPE_ULONG GAL_TYPE_UINT64
#endif

To get rid of all of the error: unknown type name 'xxx' errors, a dirty fix would be manually add #include <stddef.h> to config.h, array.h, polygon.h, qsort.h, pointer.h, box.h and add #include <gnuastro/list.h> to array.h.

I posted the generated wrappers here: LibGnuastro.jl · GitHub

1 Like

Thanks for troublshooting. I am actually planning to create a fully functional Julia wrapper for GNUAstro. A direct interface to access GNUAstro and a Julia style interface to access it.

1 Like

@Gnimuc I am having a similar issue with SuperLU_MT. I get these error messages:

error: unknown type name 'int_t'

From the SuperLU_MT FAQ I got this: “The parallel SuperLU_DIST declares integers as “int_t”, which can be defined as “int” or “long int” at compile time” But I am not sure if this is an issue with the Yggdrasil build or with the clang script.

This is my script (running in Mac Big Sur:

using Clang
using SuperLU_MT_jll

# `outpath` specifies, where the julian wrappers would be generated.
# If the generated .jl files are ok, they have to be copied to the "src" folder
# overwriting the old ones
const outpath = normpath(joinpath(dirname(@__FILE__), "superlumt_wrapped_api"))
mkpath(outpath)

# Find all relevant SuperLU MT headers
const LIBCLANG_INCLUDE = joinpath(SuperLU_MT_jll.artifact_dir, "include") |> normpath
if !isdir(LIBCLANG_INCLUDE)
    error("SUPERLU MT C headers not found.")
end

const LIBCLANG_HEADERS = [joinpath(LIBCLANG_INCLUDE, header) for header in readdir(LIBCLANG_INCLUDE) if endswith(header, ".h")]

wc = Clang.init(
    headers = LIBCLANG_HEADERS,
    output_file = joinpath(outpath, "libsuperlumt_api.jl"),
    common_file = joinpath(outpath, "libsuperlumt_common.jl"),
    header_wrapped = (root, current) -> root == current,
    clang_includes = [CLANG_INCLUDE; LIBCLANG_INCLUDE],
    clang_args = String["-I" * header for header in Clang.find_std_headers()],
    header_library = x -> "libsuperlumt",
    clang_diagnostics = true,

)

run(wc)

@jdlara-berkeley _LONGINT is defined here in the build script of SuperLU_MT_jll, so I think you need to pass this -D_LONGINT to clang_args.

clang_args = String["-I" * header for header in Clang.find_std_headers(), "-D_LONGINT"]

/* Define my integer type int_t */
#ifdef _LONGINT
typedef long long int int_t;
#define IFMT "%lld"
#else
typedef int int_t; /* default */
#define IFMT "%8d"
#endif

BTW, it looks like the build script has more definitions, you might need to get all of these definitions passed correctly into clang_args.