Setup Eclipse for GTK-4.0
17:42 11 May 2023

Intro

I'm getting started with GTK. I chose Eclipse as IDE. Right now I am at the first page of the GTK tutorial (https://docs.gtk.org/gtk4/getting_started.html).

#include 
//#include 
//#include "/usr/lib/libLLVM-15.so"

static void
activate (GtkApplication* app,
          gpointer        user_data)
{
  GtkWidget *window;
...

I compiled with

gcc $( pkg-config --cflags gtk4 ) -o example-0 example-0.c $( pkg-config --libs gtk4 )

and it compiles and executes.

Problem

My problem is that Eclipse can't resolve #include and the GTK syntax. I found some (mostly old) Questions that targeting this (I've read about to include pkg-config --libs gtk4 --cflags gtk4 to the project path - I don't know how to do that) but I was not able to solve my problem.

I've tried

Solution provided by BobMorane

adding $(pkg-config --libs gtk4 --cflags gtk4) to Project -> Properties -> C/C++ build Command line pattern

adding $$(pkg-config --libs gtk4 --cflags gtk4) to Project -> Properties -> C/C++ build Command line pattern

adding

-I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib/graphene-1.0/include -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  

Project -> Properties -> C/C++ build Command line pattern.

The last 3 did not change the compiler command which was:

gcc -O0 -g3 -Wall -c -fmessage-length=0  -MMD -MP -MF"example-0.d" -MT"example-0.o" -o "example-0.o" "../example-0.c"

Installing PKG-config support for Eclipse CDT 1.0.0

Replacing #include with #include which resulted with this error:

/usr/include/gtk-4.0/gtk/gtk.h:30:10: fatal error: gtk/css/gtkcss.h: No such file or directory

Nothing that I've tried worked. What I want to achieve

Syntax highlighting and compiling from the IDE. How to do this in Eclipse 2023-03 (4.27.0)?

What worked for me

  1. Creating a empty Meson project
  2. example-0.c from the tutorial page
  3. Creating meson.build file

my meson.build:

project('monitorUpdater', 'c') 
dependencies = [ 
  # dependency('gtk+-3.0'), 
  dependency('gtk4'), 
  dependency('openssl'), 
  dependency('X11')
]

sources = [
    'example-0.c'
]

executable('gtkTest', sources, dependencies : dependencies)

IntelliSense, building and running works.

c gtk eclipse-cdt