How to code GTK applications with Gnome-builder?

Hello everyone!. After going through the basics of C, I’ve decided I tried to learn GTK.

I’m using Fedora Linux 33, while using the latest Gnome-Builder package from Flatpak.

I and following the getting started guide from the GTK documentation here.
Code compiles and runs properly as expected, but Gnome-Builder spews out underlined errors everywhere as ween below.

What must I do to fix these issues, and how must I configure Gnome-builder to work with GTK?

note That I have installed the dev versions of GTK4 and GTK3 as stated in the getting started part of GTK documentation.

From what I can see in your screenshot you are building your program manually on the command line. But Builder needs you to setup a minimal buildsystem so it can build and run your program. Nowadays the way to go is to use the meson build system. If you create a new project from one of the templates in Builder, you’ll already have a basic GTK window example with all the buildsystem set up, so you might want to try that and edit the source files under the src directory to start coding then. Alternatively you can use a very minimal meson snippet as explained in Meson’s documentation (which uses a GTK example even :slight_smile: ).

1 Like

My issue isn’t with the build system necessarily. It’s the syntax highlighting and error displays.

If you look at the screenshot, almost every gtk related line is highlighted as if there were a syntax error, even #include <gtk/gtk.h>

I want to know how to remove these syntax error like underlines.

That’s exactly what I am saying: Builder has no way to know that your C files laying around in this folder need to be linked with gtk4 to produce an executable (it could be a library after all, but it can’t know it since you have no buildsystem). And to provide syntax highlighting and error display, it uses clang which needs to know how to build your C files, which Builder is able to provide only if there is a buildsystem it can ask those informations to (i.e. dependencies, files to build, build flags).

1 Like

Ah. I understand now. Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.