1

I have been trying to get started on GTK for Mac. I followed the installation steps and ran the hello-world program. I keep getting this error with gcc, though. Running

gcc $(pkg-config --cflags gtk4) -o hello-world-gtk hello-world-gtk.c $(pkg-config --libs gtk4) 

returns the following errors:

Package gtk4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk4' found
Package gtk4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk4' found
hello-world-gtk.c:1:10: fatal error: 'gtk/gtk.h' file not found
#include <gtk/gtk.h>
         ^~~~~~~~~~~
1 error generated.

I found a similar problem here, but the user says they already have gcc/g++ working. I don't.

Any ideas? I ran the installation script included in the installation steps and nothing changes.

Also, I have tried replacing the line

#include <gtk/gtk.h>

with

#include <gtk-2.0/gtk/gtk.h>

I then get this error:

Package gtk4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk4' found
Package gtk4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk4' found
In file included from hello-world-gtk.c:1:
/usr/local/include/gtk-2.0/gtk/gtk.h:32:10: fatal error: 'gdk/gdk.h' file not
      found
#include <gdk/gdk.h>
         ^~~~~~~~~~~
1 error generated.

If I add the flags -I/usr/include/gtk-2.0 -lgtk2.0 to my compile statement, I get the same error.

  • In Linux, one can execute the command "pkg-config --list-all" to list out all of the packages. If your Mac has that command, you might run that and see for sure if "gtk4" is in the list. – NoDakker Sep 05 '22 at 01:45
  • @NoDakker I found several different `gtk`s on the list, but none which were `gtk4`. I followed all the instructions on the site for installation. What am I missing? – Infection Tag Sep 05 '22 at 15:29
  • Not sure what you might have missed. Linux is a bit different from Macs. – NoDakker Sep 05 '22 at 17:32

0 Answers0