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.

  • said@lemmy.sdf.org
    link
    fedilink
    arrow-up
    1
    ·
    2 hours ago

    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).

  • communism@lemmy.ml
    link
    fedilink
    arrow-up
    8
    ·
    12 hours ago

    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
      link
      fedilink
      English
      arrow-up
      2
      ·
      5 hours ago

      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 than something like Qt.

  • replicat@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    11 hours ago

    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.

  • brisk@aussie.zone
    link
    fedilink
    arrow-up
    6
    ·
    13 hours ago

    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
      link
      fedilink
      arrow-up
      3
      ·
      11 hours ago

      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.

  • promitheas@programming.dev
    link
    fedilink
    arrow-up
    22
    arrow-down
    1
    ·
    edit-2
    19 hours ago

    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.

  • refalo@programming.dev
    link
    fedilink
    arrow-up
    10
    ·
    edit-2
    17 hours ago

    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
      link
      fedilink
      arrow-up
      3
      ·
      13 hours ago

      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.

  • AnarchoSnowPlow@midwest.social
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    15 hours ago

    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
      link
      fedilink
      arrow-up
      1
      ·
      15 hours ago

      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.

  • zener_diode@feddit.org
    link
    fedilink
    arrow-up
    7
    ·
    18 hours ago

    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.

    • olenkoVD@lemmy.dbzer0.comOP
      link
      fedilink
      arrow-up
      5
      ·
      18 hours ago

      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 :)

  • SorteKanin@feddit.dk
    link
    fedilink
    arrow-up
    2
    arrow-down
    5
    ·
    12 hours ago

    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
      link
      fedilink
      arrow-up
      5
      arrow-down
      2
      ·
      10 hours ago

      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
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        3 hours ago

        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.

      • thingsiplay@beehaw.org
        link
        fedilink
        arrow-up
        3
        ·
        5 hours ago

        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.

    • Rikudou_Sage@lemmings.world
      link
      fedilink
      arrow-up
      6
      ·
      18 hours ago

      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.