PMunch / futhark

Automatic wrapping of C headers in Nim
MIT License
367 stars 19 forks source link

Cannot import "fcgiapp.h" - Fatal: 'stdarg.h' file not found #39

Closed mk1nz closed 2 years ago

mk1nz commented 2 years ago

Futhark cannot find va_list declared in stdarg.h: Hint: Running: opir /home/lenz/.cache/nim/main_d/futhark-includes.h [User] Fatal: 'stdarg.h' file not found Tried to parse: /home/lenz/.cache/nim/main_d/futhark-includes.h

va_list needed by proc FCGX_VFPrintF*(stream: ptr FCGX_Stream; format: cstring; arg: va_list): cint {.header: "fcgiapp.h", varargs.}

Example code attached: test.zip .

PMunch commented 2 years ago

Please don't share your code as a zip archive. Rather create a minimal sample and post it here as a code snippet..

PMunch commented 2 years ago

You appear to not have provided any paths for Futhark, otherwise opir would have a couple -I flags. That might be the source of your troubles.

mk1nz commented 2 years ago

When I add paths pointing to header locations:

importc:
    sysPath "/usr/include"
    path "/usr/include"
    "fcgiapp.h"
Compiler warns about iteration limit:
/home/lenz/test/fcgi_app.nim(6, 1) template/generic instantiation of `importc` from here
/home/lenz/.nimble/pkgs/futhark-0.6.1/futhark.nim(476, 14) template/generic instantiation of `importcImpl` from here
/home/lenz/.choosenim/toolchains/nim-1.6.6/lib/pure/pathnorm.nim(31, 5) Error: interpretation requires too many iterations; if you are sure this is not a bug in your code, compile with `--maxLoopIterationsVM:number` (current value: 10000000)

If I raise that limit, compiler utilizes all available ram, then OOM kilss the compiler process. I had similar issue with c2nim, and solved it by preprocessing header: gcc -E /usr/include/fcgiapp.h -o fcgiapp_pre.h. After that c2nim successfully reads the header.

PMunch commented 2 years ago

Yes, you shouldn't add /user/include as a path. But you need to supply the C library location for your compiler, see the example in the README and how I add the clang path there

mk1nz commented 2 years ago

Thank you, PMunch for the help. Now it worked! I will close the issue.