GUI library for C?
from olenkoVD@lemmy.dbzer0.com to programming@programming.dev on 14 Dec 2025 15:30
https://lemmy.dbzer0.com/post/59587284

There are some times that I make something and the terminal isn’t enough. I want to make it user-friendly and add buttons and dropdowns and stuff. I mainly write C, so I want a well-known and good GUI library for C. I have tried learning Qt but the documentation was awful and all the examples were for C++ or Python. I also am aware about libraries like imgui but it’s more for debugging UIs I think and not for normal applications that end users use.

I also would like the library to be platform-agnostic, or at least just work with Linux because that’s what I am using.

If you also code in C, what do you use to make GUIs? What do you suggest me to use?

Thanks in advance.

Also, if anyone suggests Electron or anything involving a browser, I will find them and remove one electron from each atom of theirs, turning them into smoke.

#programming

threaded - newest

rikudou@lemmings.world on 14 Dec 2025 15:34 next collapse

Gtk?

olenkoVD@lemmy.dbzer0.com on 14 Dec 2025 16:27 collapse

I had tried GTK in the past and I remember it’s documentation as having like 5 examples and then letting you completely on your own. Maybe however it has changed since then, I will have a look :)

promitheas@programming.dev on 14 Dec 2025 15:38 next collapse

Also, if anyone suggests Electron or anything involving a browser, I will find them and remove one electron from each atom of theirs, turning them into smoke.

This made me laugh, it was so unexpected xD

Also, while its not an answer for your question, look up ncurses if you dont know it. It might be a middle ground for your future projects, if you prefer staying in the terminal but having a UI.

thenextguy@lemmy.world on 14 Dec 2025 15:48 next collapse

GTK, FLTK, wxWidgets,

severalkittens@ani.social on 14 Dec 2025 17:05 next collapse

Wxformbuilder is a pretty good gui builder as well!

Eldritch@piefed.world on 14 Dec 2025 17:17 collapse

Qt.

thenextguy@lemmy.world on 14 Dec 2025 17:20 collapse

He already ruled out Qt.

Eldritch@piefed.world on 14 Dec 2025 17:27 collapse

Ah, fair enough. Reading failure in my part.

thingsiplay@beehaw.org on 14 Dec 2025 16:18 next collapse

Just use Electron.

rikudou@lemmings.world on 14 Dec 2025 16:58 next collapse

How about no? If you want a web app, at least go to the trouble of writing a proper offline PWA. It behaves like an app and doesn’t force you to have a second, insecure copy of a browser.

who@feddit.org on 15 Dec 2025 05:37 next collapse

They asked for a GUI library, not an inflatable whale.

thingsiplay@beehaw.org on 15 Dec 2025 05:41 collapse

But it was promised that each electron from my body will be removed, until I’m smoke only. I assume this will take an eternity, but I’m here for science.

olenkoVD@lemmy.dbzer0.com on 15 Dec 2025 16:46 collapse

Last words?

[deleted] on 15 Dec 2025 16:50 next collapse
.
thingsiplay@beehaw.org on 16 Dec 2025 02:48 collapse

Like, Subscribe and ring the bell.

zener_diode@feddit.org on 14 Dec 2025 17:14 next collapse

This one isn’t super well known, but for small projects I really like raylib, and raygui. It gets impractical for complex GUIs, but it does make it really easy to quickly start something from scratch.

e8d79@discuss.tchncs.de on 14 Dec 2025 17:33 next collapse

Technically win32 is cross-platform if you are using wine…

refalo@programming.dev on 14 Dec 2025 18:08 next collapse

I have tried learning Qt but the documentation was awful

I found the Qt documentation to be quite excellent, with tons of examples and a huge community.

But for C I typically use nuklear. There’s also microui.

Thorry@feddit.org on 14 Dec 2025 21:32 collapse

I’m going to have to second the Qt documentation assessment. They have very good documentation and there’s also a lot of books available about Qt. I always prefer a good book as opposed to online docs. But I learned to program before the internet was a thing, so reading books for documentation was the norm for me for a long time.

ulterno@programming.dev on 15 Dec 2025 16:22 collapse

I find it really hard to relate to people not liking Qt Documentation.
Specially if you use qtcreator, you get to simply F1 any Qt class and you are sent straight to the documentation specific to that thingy.

Then there are cases where on top of normally telling what a function does, the docs also give an idea about the performance considerations, other than just the space/time complexity.

Granted there are some gaps when doing more advanced things like sub-classing an item-delegate, but:

  • When sub-classing a class, you are expected to do more than just read the docs
  • There are really good examples that more than fill that gap.

Of course, if you just want to download an older version of Qt, like 5.14 and use QML with it, you are in for a task.

Also, you are expected to understand C++ concepts before starting Qt, because that’s not what its docs are intended to teach you.

P.S.: a lot of the phrases are intended for those who found the Qt Docs “awful”

Traister101@lemmy.today on 14 Dec 2025 19:27 next collapse

Clay seems really neat but I don’t write C

AnarchoSnowPlow@midwest.social on 14 Dec 2025 19:46 next collapse

I generally don’t do GUIs for C. But I’m also an embedded C person.

When I have I’ll generate DLLs for the C portion then just pull them into a python based interface or something with easier to deal with gui implementations.

Programming languages are tools. Would you use a wrench to drive a nail? You could. But it would be painful, you’re gonna miss and whack your hand at least once.

If it’s a learning exercise, go for the C implementation, why not? I’ve written an XML parser in LabVIEW. (I never stopped to ask whether I should…) Is that the right tool for the job? Fuck no.

If this is an exercise in software engineering be an engineer and use the 99% already built and verified system to do the job it’s meant to.

Or you can write an entire theme park simulator in assembly because you like pain or something.

_cnt0@sh.itjust.works on 14 Dec 2025 20:15 collapse

Or you can write an entire theme park simulator in assembly because you like pain or something.

Say what you will, but that was an economically viable route to take. I’m still in love with TTD and RCT2.

brisk@aussie.zone on 14 Dec 2025 21:23 next collapse

I’ve used GTK and WxWidgets for C programs. GTK is more powerful but takes longer to get used to its idioms as I recall

Lee@retrolemmy.com on 15 Dec 2025 00:13 collapse

I’ve used WxWidgets and Win32 API in C. I suspect OP will quickly learn why electron is popular even though it’s so bloated. That said, sounds like OP wants a light weight and cross platform option, so WxWidgets gets my vote. Granted it’s been over 10 years since I’ve used it.

SorteKanin@feddit.dk on 14 Dec 2025 22:36 next collapse

I know it’s not really what you’re asking, but have you considered learning Rust? In many ways, Rust is more similar to C than C++ and is just as capable. There are quite a few very well documented (as is common in the Rust ecosystem) Rust libraries for GUIs, including efficient native ones or immediate mode ones and such. Just a suggestion.

count_duckula@discuss.tchncs.de on 15 Dec 2025 01:14 next collapse

You probably love Rust as much as I do, but this is such an unhelpful comment. Dude mainly programs in C, asks about libraries for C, and you don’t even bother to list any native Rust libs that may give OP an incentive to even consider learning Rust.

SorteKanin@feddit.dk on 15 Dec 2025 07:34 collapse

I think that’s quite harsh. As I said, I know it’s not what OP asked and it was just a suggestion. I’m just adding it as an option. Perhaps someone else reading the thread will find it useful, if not OP (who I don’t think you should speak for).

OP mentioned they want native speed and were struggling with badly documented libraries. I feel like it was appropriate to at least mention Rust, considering those two things. Since when is widening a discussion slightly considered bad? You don’t have to reply to my comment either, if my comment does not seem interesting to you. Let alone downvote it. You can just leave it alone, it doesn’t hurt anyone.

FishFace@piefed.social on 15 Dec 2025 09:28 next collapse

Jesus Christ

ulterno@programming.dev on 15 Dec 2025 16:12 next collapse

+1 for being the kind of guy that goes to a Windows problem thread and suggests installing Linux (I have done that just for fun), but for Rust.

I am currently learning Rust in my freer time and found “Rust by Example” not as appealing.
For context, I learnt C when I was a kid, following “Programming with C - Schaum Series” and loved how it started by giving an idea of the memory representation for all data structures the way it is abstracted (or not so much) in C. Later in Uni, I hated “Let us C” (even though it seemed to do a similar thing at a glance) and “Let us C++” and just learnt the languages on the go as required by courses and projects (also simply used a C++ reference book instead of a course styled one).

Now I see “Rust by Example” and see some parts not having been explained in the beginning, for which I would have to open the link to a section, much further ahead (it probably is not a course styled thingy). I will end up learning it, given time, but is there some material available that has a similar approach to introducing programming with Rust as the Schaum Series one was for C?

SorteKanin@feddit.dk on 15 Dec 2025 18:33 collapse

Have you tried the Rust book? I learned via that and it’s great.

ulterno@programming.dev on 16 Dec 2025 03:31 collapse

the Rust book

Do you mean this? doc.rust-lang.org/book/

I actually started with that, but somehow redirected to “Rust by Example” and realise they were different, probably because of the same domain name and theme.
Now I see, they did start with explaining ownership, which is one of the things I felt that i was missing, when I started moving forward in “Rust by Example”. Thanks for putting me back on track.

brisk@aussie.zone on 15 Dec 2025 22:26 collapse

I’ve recently started a handful of projects exploring the rust gui ecosystem and the experience has been… disappointing.

  • The most mature native library I’ve seen is Druid, which is deprecated in favour of Xilem. Xilem is highly experimental.

  • Slint is somehow used by several industry partners, yet is incapable of rendering flowing text documents, and only just brought in text formatting (via Xilem’s text library oddly enough).

  • Egui seems a bit more capable, but it has the usual downsides of immediate mode gui without any of the typical upsides (you can’t intermingle gui elements with logic, the gui has to all go in one place).

  • Dioxus is reasonably capable but is absolutely webtech focused, which seems likely anathema to Op.

  • Iced I haven’t used beyond hello world, and I didn’t enjoy that experience.

AFAICT the most mature rust gui libraries are the rust bindings for C’s GTK and C++'s Qt.

I also - somewhat controversially - disagree with “very well documented”. Rust projects consistently have published API references - which is great! The actual quality of the API references is mixed. Actual documentation - such as intended usage, common patterns, design intent - are much more sparse. Of the GUI libraries I listed, only Dioxus and Slint come close.

communism@lemmy.ml on 14 Dec 2025 22:57 next collapse

GTK? Depends on how important cross-platform support is for you. I’ve heard GTK programs don’t look great on Windows, but it does support Windows. GTK is written in C as well—Qt is in C++ so that might be where some of your problems are coming from, I’ve not tried making any kind of GUIs in C though.

who@feddit.org on 15 Dec 2025 05:32 collapse

I’ve heard GTK programs don’t look great on Windows,

They don’t look great anywhere, not even on Linux, unless you happen to be using a Gtk-based desktop.

However, Gtk does have one thing going for it: the API is native to C, so it is easier to work with in that language (and easier to bind to other languages) than something like Qt would be.

communism@lemmy.ml on 15 Dec 2025 13:12 collapse

If you use a gtk theme they look fine. Most Linux users will have a gtk theme.

who@feddit.org on 15 Dec 2025 21:29 collapse

Some Linux users will have a theme for Gtk apps that make them look somewhat like their desktop’s native apps, but they often still look out of place. And Gtk has long had a habit of breaking those themes in minor version updates. And modern Gtk pushes client-side window decorations, which completely defeat window manager functionality that is native to non-Gtk desktops, making the app not only look terrible but also not behave correctly. And even if a perfectly matched theme existed (I have never seen one), the inputs for common controls won’t be the same as native ones, so the app won’t operate correctly.

In other words, nope, what you are referring to does not solve the problem.

replicat@lemmy.world on 14 Dec 2025 23:28 next collapse

You could just use SDL. Very easy to integrate into a C project. BUT SDL doesn’t come with any UI primitives so you will need to make buttons, sliders etc yourself.

said@lemmy.sdf.org on 15 Dec 2025 08:29 next collapse

I don’t know how feasible for you to use an immediate mode GUI library but imgui came to my mind as soon as i read the post. However it’s written in C++ instead of C.

I never tried the C bindings but it seems to have a couple of options including cimgui to use imgui in a C project.

Maybe it’s worth a shot if you want something that’s proven to be lightweight and battle tested (I mean the main imgui project for this).

ulterno@programming.dev on 15 Dec 2025 15:51 next collapse

Apart from GTK, wxWidgets (wxC) and FLTK (cfltk), which others have already stated and are more geared towards desktop UI, you can consider SDL3 for a more open ended graphics library. It’s good for making game engines.

iza@lemmy.zip on 15 Dec 2025 19:02 next collapse

There’s a couple interesting libraries that abstract different toolkits under the hood (GTK on Linux, Win32 on Windows). I’m not sure how they compare to using GTK directly. IUP, libui

Jankatarch@lemmy.world on 15 Dec 2025 19:36 next collapse

Raylib+raygui is my favorite for getting started because how simple they are. I also heard good things about clay.

For professional UI libraries with buttons etc similar to qt, I know of GTK, EFL, and iup portable.

GTK is the main one I can vouch for. Google sometimes gives gtk-3 docs and sometimes gtk-4 docs so just remember to use docs’ searchbar.

Also consider TUI instead of GUI if you really want C. These libraries usually support mouse too.

FizzyOrange@programming.dev on 16 Dec 2025 18:28 collapse

Best option is to switch to C++ and use QtWidgets. You don’t need to know much C++ for that - if you want to tediously micromanage strings you can still do that in your business part of the program.