Help with Windows-related errors

Hello,

I’m trying to install the caisar opam package on Windows (using a default install with mingw, on a PowerShell, on Windows 11 after using winget to install opam).

The first issue I had, was the dependency ocaml-protoc-plugin, which requires conf-protobuf, and the fact that such package has no depext for Windows. I tried installing libprotobuf-devel with Cygwin and it worked, so I think I’ll add a patch for it on opam-repository:

+  ["libprotobuf-devel"] {os = "win32" & os-distribution = "cygwinports"}

I copied the os/os-distribution constraints from conf-gmp, but I’m not sure that’s the right way to do it.

Anyway, now I’m having errors compiling ocaml-protoc-plugin, related to pkg-config. pkg-config is already installed and, if I open a Cygwin terminal, the pkg-config command seems to work. But when dune tries to install it, I get:

[ERROR] The compilation of ocaml-protoc-plugin.6.2.0 failed at "dune build -p ocaml-protoc-plugin -j 7".

#=== ERROR while compiling ocaml-protoc-plugin.6.2.0 ==========================#
# context     2.5.0 | win32/x86_64 | ocaml.5.4.0 | https://opam.ocaml.org#302e116c4009da2f5a31c350a57c8b3c9b27289e
# path        C:\Users\user\AppData\Local\opam\default\.opam-switch\build\ocaml-protoc-plugin.6.2.0
# command     C:\Users\user\AppData\Local\opam\default\bin\dune.exe build -p ocaml-protoc-plugin -j 7
# exit-code   1
# env-file    C:\Users\user\AppData\Local\opam\log\ocaml-protoc-plugin-24808-db4f28.env
# output-file C:\Users\user\AppData\Local\opam\log\ocaml-protoc-plugin-24808-db4f28.out
### output ###
# File "src/google_types/dune", line 11, characters 15-25:
# 11 |           (run pkg-config protobuf --variable=includedir))))
#                     ^^^^^^^^^^
# Error: Program pkg-config not found in the tree or in PATH
#  (context: default)

I’m not sure why this is happening; is it something in the dune file of ocaml-protoc-plugin that is not compatible with Windows? Is this a more fundamental limitation related to OCaml on Windows? Am I missing a command?

I remember in the past I had to do specific steps for cygwin-related depexts to work (e.g. add some directories to PATH), but I think that’s no longer required.

Hi,

To fix the Windows build of the libarchive bindings I’m working with, I referenced a cross-compilation package (your compiler targets x86_64-w64-mingw32 so it won’t look in the same directory). There was also a build dependency on conf-pkg-config that shoud fix your path issues. Your depext should look like this:

["mingw64-x86_64-libprotobuf"] {os="win32" & os-distribution="cygwin"}

Unfortunately, this package doesn’t exist yet…

Hope this helps!

By “this package”, you mean the Cygwin package does not exist? Because indeed I see no such package in the list. So it means I should wait until someone creates a mingw package for protobuf, and only then will I be able to use it on my mingw-based OCaml for Windows?

Yes, I referred to the Cygwin package. Here’s the Cygwin Package Contributor’s Guide, maybe you could get inspiration from existing cross-compiled packages.

1 Like