Idris2 icon indicating copy to clipboard operation
Idris2 copied to clipboard

Failure to compile FFI-readline example on nix.

Open locallycompact opened this issue 4 years ago • 5 comments

Hi. I get this error when I try to build the FFI-readline example.

[I] lc@aiur ~/S/g/i/I/s/FFI-readline (master) [127]> nix-shell -p readline --command 'idris2 --build readline.ipkg'
make: Entering directory '/home/lc/Source/github.com/idris-lang/Idris2/samples/FFI-readline/readline_glue'
gcc -Wall  -fPIC   -c -o idris_readline.o idris_readline.c
In file included from /nix/store/ahsfc5f18l7y25ykp10cp6wfqcp5qwvq-readline-6.3p08-dev/include/readline/readline.h:35,
                 from idris_readline.c:1:
/nix/store/ahsfc5f18l7y25ykp10cp6wfqcp5qwvq-readline-6.3p08-dev/include/readline/rltypedefs.h:71:28: error: unknown type name ‘FILE’
   71 | typedef int rl_getc_func_t PARAMS((FILE *));
      |                            ^~~~~~
In file included from /nix/store/ahsfc5f18l7y25ykp10cp6wfqcp5qwvq-readline-6.3p08-dev/include/readline/readline.h:36,
                 from idris_readline.c:1:
/nix/store/ahsfc5f18l7y25ykp10cp6wfqcp5qwvq-readline-6.3p08-dev/include/readline/rltypedefs.h:1:1: note: ‘FILE’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
  +++ |+#include <stdio.h>

locallycompact avatar Mar 12 '21 18:03 locallycompact

We don't seem to have continuous integration for the content of samples/. Still, I was able to compile the file on ubuntu after installing libreadline-dev. Could it be that this is an upstream issue in the readline package nix uses?

gallais avatar Mar 15 '21 14:03 gallais

That seems likely.

locallycompact avatar Mar 15 '21 16:03 locallycompact

Looks like it's in readline. The manpages imply you have to manually #include <stdio.h> first. At least Arch and NixOS have this issue, so maybe Ubuntu modifies libreadline-dev?

Adding that line allows me to build in NixOS.

claymager avatar Apr 07 '21 16:04 claymager

Okay I've tried adding this extra line too and it does not break the build on Ubuntu AFAICT. I'll be happy to merge a PR including that line & adding samples to the CI.

gallais avatar Apr 08 '21 11:04 gallais

Given that it seems this was an issue in the nix repo, maybe it is worth revisiting whether this is still an issue over a year later.

ProofOfKeags avatar Jun 28 '22 21:06 ProofOfKeags