30

I already asked this question at apple.stackexchange.com, but I was told it was the wrong place for this question - so I will ask it here, as I was suggested to do.

At my university we got the task to implement a c-program which has a GTK-GUI. The GTK-GUI is already implemented, we just have to implement a algorithm which hands it some data.

I already got gcc/g++ working. But when i try to compile the project the compiler returns the error, that it does not find the gtk:

fatal error: 'gtk/gtk.h' file not found #include <gtk/gtk.h> ^ 

So my question is: How do I install gtk on OSX Mavericks for using it with gcc/g++ compiler?

My setup: MacBook Pro Retina Mid 2012 with OSX Mavericks. Homebrew is installed and working if it could be useful for the installation.

(Of course the Apple Command Line Developer Tools are installed)

2
  • 1
    Fix your include path if gtk headers aren't available in the default include path. Commented Nov 20, 2013 at 14:41
  • 1
    @devnull I'm afraid I don't know how to do that. Commented Nov 20, 2013 at 14:45

2 Answers 2

59

I finally solved the Problem. tojanfoe suggested in a comment the link http://www.hardcoded.net/devlogs/20120426 which turned out to not be helpful.

This is how i solved it:

1.a) Installation of GTK+ 2.x:

brew install gtk+ 

1.b) Installation of GTK+ 3.x:

You can install gtk+ 3.x via home brew too if you need that, but the 2.x version is enough for my purposes. The command would be:

brew install gtk+3 

2.) But after the installation I had the problem, that cairo could not be found. So i solved it this way:

export PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.12.16/lib/pkgconfig/ 

3.) Then the compiler said it could not find the package 'xcb-shm', required by 'cairo'. This can be solved this way:

export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig 

After this command the compiler worked as expected.

Sign up to request clarification or add additional context in comments.

4 Comments

where is gtk.h located on your system after install?
@user391339 gtk.h is in /usr/local/Cellar/gtk+/2.24.31_1/include/gtk-2.0/gtk/gtk.h found using pkg-config --cflags gtk+-2.0
some GTK2 apps require: brew install gtkglext
@user391339 At the end of the installation, it shows the gtk path. Now you do: find /usr/local/Cellar/gtk+3 -name gtk.h
3

You can download precompiled Gtk2 Framework from: http://r.research.att.com http://r.research.att.com/libs/GTK_2.24.17-X11.pkg, or http://r.research.att.com/libs/GTK_2.18.5-X11.pkg

And Gtk3 Framework from: http://www.tarnyko.net/dl/gtk.htm

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.