Installing labgtk3 on Diskuv

I have finally managed to install lablgtk3 on Diskuv. Here are the steps to proceed.

Install Visual Code 2022 (the compiler VS 2019 from Diskuv doesn’t like the very long string gtkrsesources from Gtk)

According to GitHub - wingtk/gvsbuild: GTK stack for Windows, install MSYS2 and Python, then

python -m pip install --user pipx
python -m pipx ensurepath
pipx install gvsbuild​
gvsbuild build gtk3

Copy the content of C:\gtk-build\gtk\x64\release in a new directory C:\gtk.

Add C:\gtk\bin to the PATH. (Needed for labgtk3/cairo2 to find pkg-config.exe)

Launch C:\users\you_user_name\AppData\Local\Programs\DiskuvOCaml\tools\MSYS2\msys2.exe, then inside the new shell perl -MCPAN -e"install IPC::System::Simple" (The command with-dkml perl -MCPAN -e"install IPC::System::Simple" hadn’t work and I don’t know why).

Get the lablgtk3 source. Patch src\dune and remove the /Wno-deprecated flag which is incompatible with the Microsoft compiler, and pin the directory.

Now opam install lablgtk3 should work.

I’m glad it worked, and at the same time that seems complicated. I was surprised that GTK needs two other languages (Perl and Python) to build OCaml bindings. But then I looked at the same instructions for GTK on Rust and it isn’t easy either.

From your instructions and the Rust ones, I’m guessing not many people use GTK on Windows. I could be wrong. Are you porting an existing GTK app? If not, would something like have the features you need? (I’m not trying to dissuade you from GTK; just curious)

Perl is needed for calmp5. gvsbuild uses Python to build Gtk itself, but not the binding itself (I guess CMake wasn’t powerful enough).

Bogue could be nice too. The last time I had needed a GUI I hadn’t a usable library at hand. Bogue could have fit my need.

Nota: I needed a file chooser, and I am not sure Bogue would bring one.

I have no specific needs today, but may have one and would prefer to have a GUI library for Ocaml.

I guess that most Windows developments use Windows widgets or if a portability is needed, Qt. But the current Qt ocaml library is not complete:

In its current state, I think that lablqml can be used to replace C++ by OCaml in small applications. In large GUI applications, we would probably still need to implement some GUI controls in compilable language (like C++). My library doesn’t allow implementing these controls in OCaml at the moment.

And the Qml way needs JavaScript bindings…

NOTE: The copy to C:\Gtk is probably not useful if the PATH contains pkg-config.exe. I was guided to a copy because of some hardcoded path in the lablgtk bindings, but this exe should feed the C compiler with good flags anyway.