Is there a way to create a Linux and Haiku app, with GUI, written in C? With minimal porting coding! Ideally with Gtk. Afaik if I stick to C, I could only use Xlib-API (shudder) and no other toolkit because native Haiku-GUI must be coded with C++ or Yab.
If you want plain C as opposed to C++, then you just said it: Gtk. Otherwise, a search for âGUI programmingâ on the forum mostly results in suggestions to use C++. Thereâs FLTK, Qt, and wxWidgets: a much wider selection. PyQt 5 and 6 are there too.
Thanks for the answer. Thatâs great to hear. I wasnât aware that all the C toolkits you mentioned are usable on Haiku. (Gtk is my favorite, Iâll try that.) I thought: Haiku-GUI = C++.
Edit: I reread your answer and see you meant that FLTK, wxWidgets etc are C++ not C, right?
Yes, thatâs right. Though FLTK only uses very light C++ features, nothing newer than the â98 standard, and you never need to declare a single class in your code.
For Qt there are C bindings: GitHub - rcalixte/libqt6c: Qt 6 for C
While Qt itself is still C++, that allows you to write your own applications in C and still use Qt with it.
Qt has the advantage on Haiku that itâs perfectly integrated and looks almost like a native application, so thatâs what Iâd strongly recommend for a multiplatform app if you also want to target Haiku.
While GTK technically works on Haiku, it does so only using a massive amount of compatibility layers (Wayland and all) and doesnât integrate at all UI-wise.
Whenever I have other choices, I avoid using GTK stuff on Haiku.
A few years ago I had started porting IUP. It is a wrapper above other GUI toolkits (a bit like wxWidgets), and so you could use that to have GTK on Linux, and native widgets on Haiku (and also win32 standard widgets on Windows and a few other things).
Its API is a bit strange as itâs mainly designed to work with Lua, but itâs the least bad thing Iâve used for GUIs in C. However, Haiku port is not maintained, and I have no plans to resume it as Cosmoe may soon be usable to port my Haiku apps to Linux, making my life a lot simpler.
I wonder why IUP still isnât in the repos of any Linux distribution, and especially Debian (which otherwise has everything under the sun). Doubly so as the long-abandoned XForms is still widely packaged.
Nuklear is also immediate mode, rather than retained mode, so thatâs something to consider if that matters to you.
You could try and see how libAgar works. Itâs a retained-mode GUI library, and while it doesnât have a Haiku port, it does have an SDL2 backend, so you could test that out and see if thatâll work.