Library for GUI?



Is anyone doing work creating GUIs in OCaml right now? If so, what GUI library are you using?

lablgtk is out of date, supporting only Gtk+2.
lablqt is now called lablqml, and the tutorial is offline. Not sure what’s going on with this library, but it seems in transition.

So is there anything up-to-date, or are people just not making use of GUI libraries?

Are any OCaml GUI bindings under active development?
GUI in ocaml ? What is used?
(WIP) Frequently Asked Questions

You can use LexiFi’s csml to interface with .NET to build UIs. Here’s an example:


Recently, I’ve been developing 2 GUIs using Tyxml_js + react (Bünzli’s) (+ Cohttp).



smondet/vecosek (unreleased yet)


I’m one of the developers or contributors to Lablqml (previously known as Lablqt).

I have used it successfully to develop a proprietary UI application used in the industry and it works great. The documentation is not there yet because the method I have used can be improved. Basically I would like to advance it a bit more.

Currently preparing a clean repository focusing on binding QML which I will document. The more attention, likes and comments the more inclined I will be to get going :slight_smile:


FYI there is a recent paper about HTML5 vs QML. There research was originated by Qt folks, so QML won :slight_smile:


I implore you to proceed with this. We definitely need good bindings to a cross-platform GUI library in OCaml. Is lablqml usable as is? I’d love to start using it.



We have discussed this before. I don’t find HTML nice to read or write.


Sure will do. Lablqml is usable, part of the bindings anyway, but you need to know what you are doing, which is currently only possible by reading the code and understanding the bindings.


Very cool! Didn’t even know this was possible. You should get it added to Awesome OCaml.

What made you decide to go in this direction? I’m thinking of the primacy of Windows and the cost of starting up a .Net process as possible downsides here.


I’ve done some Eliom-Ocsigen programming, and while it’s possibly some of the best experiences you can have for client-server web apps, it still has the overhead of html/css/DOM programming, and it requires a client-server mentality even for applications that don’t need client-server. I’d much rather not have to deal with any of that when making simple GUI-based applications, not to mention the cost of starting up a browser instance or dealing with browser slowness.


The replying with this info the first comment was lame, do I replied to the last comment where you mentioned lablqml. Sorry about that.

@bluddy I think that I fixed links to the tutorial.


Just for completeness’s sake I feel like I should mention reason-react. If you’ve ever used React.js that project is basically a set of bindings to it. It’s written in Reason which is just OCaml so you can use it from OCaml world.
I haven’t used it myself but I’ve heard that it’s pretty good :wink:


@bluddy I didn’t decide it, csml was used long before I joined my employer. But I would do the same now—I think it makes a lot of sense to develop GUIs using each platform’s native toolkit if you want the best result.


I have been working on a binding generator that addresses the difficulties of GUI libraries: arbitrary (cyclic) object graphs, non-trivial life time and control flow (non-deterministic, concurrent, etc):

It is the result of a few years of experiments with bindings and should cover the needs of GObject, Objective-C and Win32 GUI bindings.

It is still in heavy development.


Given that nobody mentionned it, there is the ocaml-efl project :

It is an OCaml interface to the Enlightenment Foundation Libraries.


There is also Ocaml bindings to wxWidget.

Haven’t used in professional capacity yet but definitely looks promising.



Fabrice said that he stopped working on it because nobody was interesting.


That’s a real shame, since wxOCaml doesn’t compile now.

It’s always good to have bindings to multiple GUI frameworks. I remember wx being particularly easy to use.


It is not that hard to make wxOCaml compile. I just did and the changes are minor

The problem is that generated code uses int32/int64 which are not valid types in C++. Replacing them with int32_t/int64_t makes everything work.

 wxStubsGen/ | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/wxStubsGen/ b/wxStubsGen/
index 68d0a34..e9b25d1 100644
--- a/wxStubsGen/
+++ b/wxStubsGen/
@@ -126,7 +126,10 @@ let   generate_method_stub_body oc cl p  out_nargs =
       let wxClass_equiv = find_cpp_equiv wxClass in

       if List.mem wxClass_equiv direct_return_types then
-        fprintf oc "  %s %s_c;\n" wxClass arg_name
+        if wxClass = "int32" || wxClass = "int64" then
+          fprintf oc "  %s_t %s_c;\n" wxClass arg_name
+        else
+          fprintf oc "  %s %s_c;\n" wxClass arg_name
         fprintf oc "  %s* %s_c = new %s();\n" wxClass arg_name wxClass;
     | Out, _ -> assert false
@@ -216,7 +219,10 @@ let   generate_method_stub_body oc cl p  out_nargs =
       let wxClass_equiv = find_cpp_equiv wxClass in

       if List.mem wxClass_equiv direct_return_types then
-        fprintf oc "%s ret_c = " wxClass
+        if wxClass = "int32" || wxClass = "int64" then
+          fprintf oc "%s_t ret_c = " wxClass
+        else
+          fprintf oc "%s ret_c = " wxClass
       else begin
         fprintf oc "%s *ret_c = new %s();\n" wxClass wxClass;
         fprintf oc "  *ret_c = ";


I saw that, but assumed there was more work to do. Does it work with this one change?