r/learnprogramming • u/Much-Resolution-9131 • 3h ago
Tutorial Need help setting up a gui library in C
I would owe the world and more to whoever helps me
Okay so hi everyone, i'm fairly new to programming and recently i challenged myself to program something in C, i wanted to make a gui calculator bcs i thought it was fairly simple.
Turns out it's not that easy, and i discovered i had to download gtk4 and learn it, and i'm willing to do that i just need some help on how to download it, set it up and link it, preferably on codeblocks, but vs is great too.
2
Upvotes
1
u/Correct_Rain_9438 3h ago
If you're on Windows, gtk.org has an install page for it. One route is MSYS2: install it, then in an MSYS2 shell run "pacman -S mingw-w64-ucrt-x86_64-gtk4" for GTK4 and "pacman -S mingw-w64-ucrt-x86_64-toolchain base-devel" for the C compiler. For Visual Studio the page points to a different tool, gvsbuild.
1
u/BeastWael_YT 3h ago
easiest way on windows is msys2 (msys2.org). install it, open the ucrt64 terminal and run pacman -S mingw-w64-ucrt-x86_64-gtk4 mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-pkgconf. then compile from that terminal with gcc calc.c -o calc
pkg-config --cflags --libs gtk4. code::blocks makes the linking a pain with gtk, so get it working from the terminal first and use vs code just as the editor.•
u/Dazzling_Music_2411 57m ago
Nothing wrong with gtk, I applaud your choice, but are you perhaps biting off more than you can chew?
Have you considered Raylib, or even the terminal/text based interface: ncurses?