Error while compaling piaf

Hello! I’m trying to use Piaf, I’m using Windows 10, opam 2.3 with internal managed Cygwin and git. I get this error when I do opam install piaf, this means Piaf can’t be used on Windows? Thankgs.

#=== ERROR while compiling piaf.0.2.0 =========================================#
# context     2.3.0 | win32/x86_64 | ocaml.5.3.0 | https://opam.ocaml.org#94514fa0d0e38616b994c0cd54c1623fd40eb357
# path        ~\AppData\Local\opam\default\.opam-switch\build\piaf.0.2.0
# command     ~\AppData\Local\opam\default\bin\dune.exe build -p piaf -j 7 @install
# exit-code   1
# env-file    ~\AppData\Local\opam\log\piaf-19128-d1b44d.env
# output-file ~\AppData\Local\opam\log\piaf-19128-d1b44d.out
### output ###
# [...]
# File "lib/dune", line 24, characters 63-75:
# 24 |   (names piaf_bigarray_read piaf_openssl_rand piaf_openssl_sha piaf_fdutils)))
#                                                                     ^^^^^^^^^^^^
# (cd _build/default/lib && C:\Users\ignacio.caamano\AppData\Local\opam\default\bin\x86_64-w64-mingw32-gcc.exe -O2 -fno-strict-aliasing -fwrapv -mms-bitfields -O2 -fno-strict-aliasing -fwrapv -mms-bitfields -g -I C:/Users/ignacio.caamano/AppData/Local/opam/default/lib/ocaml -I C:/Users/ignacio.caamano/AppData/Local/opam/default/lib/ocaml\runtime_events -I C:/Users/ignacio.caamano/AppData/Local/[...]
# lib/stubs/piaf_fdutils.c: In function 'piaf_is_fd_valid':
# lib/stubs/piaf_fdutils.c:37:9: warning: implicit declaration of function 'fcntl' [-Wimplicit-function-declaration]
# lib/stubs/piaf_fdutils.c:37:32: error: 'F_GETFD' undeclared (first use in this function)
# lib/stubs/piaf_fdutils.c:37:32: note: each undeclared identifier is reported only once for each function it appears in
# (cd _build/default/sendfile && C:\Users\ignacio.caamano\AppData\Local\opam\default\bin\x86_64-w64-mingw32-gcc.exe -O2 -fno-strict-aliasing -fwrapv -mms-bitfields -O2 -fno-strict-aliasing -fwrapv -mms-bitfields -g -I C:/Users/ignacio.caamano/AppData/Local/opam/default/lib/ocaml -I C:/Users/ignacio.caamano/AppData/Local/opam/default/lib/ocaml\unix -o sendfile_stubs.o -c sendfile_stubs.c)
# sendfile_stubs.c:102:2: warning: #warning ocaml-sendfile: sendfile(2) is unsupported on this platform. [-Wcpp]
#   102 | #warning ocaml-sendfile: sendfile(2) is unsupported on this platform.
#       |  ^~~~~~~

It does indeed look like piaf is using some Linux-specific code. You may want to open an issue upstream: GitHub · Where software is built. cc @anmonteiro

Cheers,
Nicolas

Indeed I’m not a Windows user, so Piaf is unlikely to work there. Feel free to make a PR that adds support for your use case.

Thanks for the replies. I don’t think I have the knowledge to do a PR in Piaf but I’ll think about it. I was just trying to make some http requests to learn and test OCaml, but I can’t find a library that works on Windows to try on my work machine.

If produing native Windows executables is not important, you can quickly get started by using WSL.

Cheers,
Nicolas

I prefer to avoid WSL, because in that case I can use my own laptop which has Linux, and I was looking to make a toy project involving http calls and parsing json on my work laptop. Since opam recently supported windows I gave it a try. Thanks a lot for the answers!

You could try using a curl binding like ezcurl 0.2.4 (latest) · OCaml Package - libcurl should at least work on Windows :slight_smile:

1 Like

Great! I will try that! :wink: