Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install gtk on OSX for use with g++/gcc compiler

Tags:

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)

like image 270
tmuecksch Avatar asked Nov 20 '13 14:11

tmuecksch


People also ask

Does GTK work on Mac?

Gtk is a unix graphical framework originally designed to run on Unix systems with X-Windows... but it provides multiple backends including one for MacOS's Quartz graphics engine, so it can be built to run on MacOS without enabling the X11 subsystem.


1 Answers

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.

like image 78
tmuecksch Avatar answered Oct 06 '22 00:10

tmuecksch