Compiling GTK+ on Mac OS X can be a time consuming task, specially if you don't want to use tools like Fink or MacPorts. Obviously I don't keep backup of my libs so after my last HDD crash (less than a year brand new MacBook, thanks to MacSaber) I had to redo all the GTK saga again. This time I am going to record the whole process to the history, so I can drastically reduce the efforts on future attempts.
Yes, GTK has a million dependencies that have a million dependencies themselves leaving us with a gazillion libraries to take care of. While I was going forward and back across the dependencies I wrote down what depends on what. That's what I came up with:
- gtk
- glib
- pkg_config
- gettext
- expat
- libpng
- atk
- pango
- cairo
- pixman
- freetype
- fontconfig
- libtiff
- libjpeg
For the architecture I decided to go with i686 after gettext complained about x86_64. Yes, I had to go back and re-compile everything that was already done until that step.
I like to install everything on /usr/local so I know where my stuff is laying around. Also, I tried to find the latest version of each package in the time this blog entry was written. Some stuff is hosted on more than one "official" place and not always it is updated everywhere. So I could fail on finding the state of the art for everything here but I am probably close to that.
I am not going to report any error message or to detail any problem that I faced during the process. Instead I will go direct to the point.
GLIB
we start with pkg_config:wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gzthen we move to gettext, that requires expat:
tar -zxf pkg-config-0.23.tar.gz
cd pkg-config-0.23
./configure --prefix=/usr/local CFLAGS="-arch i686"
make
sudo make install
wget http://ufpr.dl.sourceforge.net/sourceforge/expat/expat-2.0.1.tar.gzbefore going to gettext we need to hack emacs as found here:
tar -zxf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --prefix=/usr/local CFLAGS="-arch i686"
make
sudo make install
sudo mv /usr/bin/emacs-i386 /usr/bin/emacs-i386.backupfinally gettext:
sudo /usr/libexec/dumpemacs -d
wget ftp://ftp.unicamp.br/pub/gnu/gettext/gettext-0.17.tar.gzand the last item on glib, libpng:
tar -zxf gettext-0.17.tar.gz
cd gettext-0.17
./configure --prefix=/usr/local CFLAGS="-arch i686"
make
sudo make install
wget http://ufpr.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.25.tar.bz2now glib itself, that is by far more problematic than the libs above:
tar -jxf libpng-1.2.25.tar.bz2
cd libpng-1.2.25
./configure --prefix=/usr/local CFLAGS="-arch i686"
make
sudo make install
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.14/glib-2.14.6.tar.bz2at this point we have to patch glib/gutils.h as seen here:
tar -jxf glib-2.14.6.tar.bz2
cd glib-2.14.6
--- gutils.h 2008-02-07 03:24:59.000000000 -0200also the C compiler need some special flags. the SSE instructions have to be enabled with -msse2 which is mandatory here. I copied the other flags from the portfile at MacPorts. Finally:
+++ /usr/src/glib-2.14.6/glib/gutils.h 2008-03-06 16:43:34.000000000 -0300
@@ -108,6 +108,8 @@
#ifdef G_IMPLEMENT_INLINES
# define G_INLINE_FUNC
# undef G_CAN_INLINE
+#elif defined (__APPLE__)
+# define G_INLINE_FUNC static inline
#elif defined (__GNUC__)
# if __GNUC_PREREQ (4,2) && defined (__STDC_VERSION__) \
&& __STDC_VERSION__ >= 199901L
./configure --prefix=/usr/local --enable-static CFLAGS="-arch i686 -msse2 -funroll-loops -fstrict-aliasing -finline-functions" LDFLAGS="-bind_at_load"
make
sudo make install
GTK
the next is atk:wget http://ftp.gnome.org/pub/gnome/sources/atk/1.21/atk-1.21.92.tar.bz2and following cairo deps, pixman:
tar -jxf atk-1.21.92.tar.bz2
cd atk-1.21.92
./configure --prefix=/usr/local CFLAGS="-arch i686"
make
sudo make install
wget http://cairographics.org/releases/pixman-0.9.6.tar.gzfreetype:
tar -zxf pixman-0.9.6.tar.gz
cd pixman-0.9.6
./configure --prefix=/usr/local CFLAGS="-arch i686"
make
sudo make install
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.bz2fontconfig:
tar -jxf freetype-2.3.5.tar.bz2
cd freetype-2.3.5
./configure --prefix=/usr/local CFLAGS="-arch i686 -msse2"
make
sudo make install
wget http://fontconfig.org/release/fontconfig-2.4.92.tar.gzand finally cairo. note we need again the SSE instructions plus we have to specify the location of the X development libraries. If you don't have it, refer to apple support on how to install Xcode tools and X11.
tar -zxf fontconfig-2.4.92.tar.gz
cd fontconfig-2.4.92
./configure --prefix=/usr/local CFLAGS="-arch i686"
make
sudo make install
wget http://cairographics.org/releases/cairo-1.4.14.tar.gznow that we have cairo done, we can do pango:
tar -zxf cairo-1.4.14.tar.gz
cd cairo-1.4.14
./configure --prefix=/usr/local --enable-xlib --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib CFLAGS="-arch i686 -msse2"
make
sudo make install
wget http://ftp.gnome.org/pub/GNOME/sources/pango/1.19/pango-1.19.4.tar.bz2libjpeg has a special rule hidden inside the makefile, that you don't want to miss:
tar -jxf pango-1.19.4.tar.bz2
cd pango-1.19.4
./configure --prefix=/usr/local CFLAGS="-arch i686 -msse2"
make
sudo make install
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gzand the last one, libtiff:
tar -zxf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local CFLAGS="-arch i686"
make
sudo make install
sudo make install-lib
wget ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.8.2.tar.gzwe are now all ready to the big guy:
tar -zxf tiff-3.8.2.tar.gz
cd tiff-3.8.2
./configure --prefix=/usr/local --with-apple-opengl-framework CFLAGS="-arch i686"
make
sudo make install
wget http://ftp.gnome.org/pub/gnome/sources/gtk+/2.12/gtk+-2.12.8.tar.bz2and voilá ! it took me many hours to get here, I hope you can do it in minutes ;)
tar -jxf gtk+-2.12.8.tar.bz2
cd gtk+-2.12.8
./configure --prefix=/usr/local --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib CFLAGS="-arch i686 -msse2"
make
sudo make install
We are not ready for UMIT yet. We need the python bindings still. see you in the next adventure.
update: thanks to Gregory and Antoine for pointing out the typos
14 comments :
I've been trying to figure out how to install Cairo on Leopard for a couple of days now. Thanks a lot for these installation instructions. It worked perfectly for me (the cairo + dependencies part of it, atleast).
You have listed here:
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.14/glib-2.14.6.tar.bz2
tar -jxf glib-2.14.5.tar.bz2
cd glib-2.14.5
I think there's a typo there. You request glib-2.14.6 and try to extract glib-2.14.5 ;)
Hi. I'm on using a PPC Tiger and GLib will not configure. First it complained about pkg-config, so I copied pkg-config to /usr/bin, but then it complains gettext isn't installed
checking for msgfmt... no
configure: error:
*** You must have either have gettext support in your C library, or use the
*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html
I did ignore your "-arch i686" stuff since it didn't work (probably a PPC thing).
I've searched for a long time but can't get it to work.
Can you help me?
Thanks,
Bob
I have followed the steps you provided and everything works fine. However, you are not suggesting to actually install gtk in the end, with make, sudo make install.
So, after having tried, several errors arose, all of them having to do with the jpeg library formerly installed (io-jpeg.c file to be precise).
Do you have any idea?
thanks for the tutorial by the way.
Also, a small typo for the "copy-pasters" in the last commands: cd gtk+-2.12.8.tar.bz2
is not gonna work :cd gtk+-2.12.8 should do the trick.
I figured out what was wrong. It wasn't looking for msgfmt in the right place, so I did 'export PATH=/usr/local/bin:$PATH' before ./configure and it worked.
Bob
hi
thanks for the manual. However I think something is wrong here
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.14/glib-2.14.6.tar.bz2
tar -jxf glib-2.14.5.tar.bz2
cd glib-2.14.5
you download 2.14.6 but continue then with 2.15.5
Maybe you check that out
ben
I'm trying to compile tiff-3.8
and I get past the ./configure, but when I try to make I get the following error:
/bin/sh ../libtool --tag=CC --mode=link gcc -arch i686 -Wall -W -o tiffgt tiffgt-tiffgt.o ../libtiff/libtiff.la ../port/libport.la -L/usr/X11/lib -framework GLUT -lobjc -framework OpenGL -ljpeg -lz -lc
libtool: link: gcc -arch i686 -Wall -W -o .libs/tiffgt tiffgt-tiffgt.o ../libtiff/.libs/libtiff.dylib ../port/.libs/libport.a -L/usr/X11/lib -framework GLUT -lobjc -framework OpenGL -ljpeg -lz -lc
ld: cycle in dylib re-exports with /usr/X11/lib/libGL.dylib
collect2: ld returned 1 exit status
make[1]: *** [tiffgt] Error 1
make: *** [all-recursive] Error 1
I have looked at following solution, but how do I do this if I have a Makefile.
I have tried adding the following line to the Makefile LDFLAGS = line, recompiled w/o success... any info from you'all?
// salvador
forgot to past the fixes I found:
http://lists.apple.com/archives/X11-users/2007/Oct/msg00146.html
http://wiki.finkproject.org/index.php/Fink:Packaging:Preparing_for_10.5#OpenGL_Bug
God bless you!
Hi I've done everything you've listed here.
But it fails on installation of atk. This is when i run configure.
Hope you can give some insight. The error is as follows:
checking for GLIB - version >= 2.5.7... no
*** Could not run GLIB test program, checking why...
*** The test program compiled, but did not run. This usually means
*** that the run-time linker is not finding GLIB or finding the wrong
*** version of GLIB. If it is not finding GLIB, you'll need to set your
*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point
*** to the installed location Also, make sure you have run ldconfig if that
*** is required on your system
***
*** If you have an old version installed, it is best to remove it, although
*** you may also be able to get things to work by modifying LD_LIBRARY_PATH
checking for pkg-config... (cached) /usr/bin/pkg-config
checking pkg-config is at least version 0.16... yes
checking for GLIB - version >= 2.0.0... no
*** Could not run GLIB test program, checking why...
*** The test program compiled, but did not run. This usually means
*** that the run-time linker is not finding GLIB or finding the wrong
*** version of GLIB. If it is not finding GLIB, you'll need to set your
*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point
*** to the installed location Also, make sure you have run ldconfig if that
*** is required on your system
***
*** If you have an old version installed, it is best to remove it, although
*** you may also be able to get things to work by modifying LD_LIBRARY_PATH
configure: error:
*** GLIB 2.0.0 or better is required. The latest version of
*** GLIB is always available from ftp://ftp.gtk.org/. If GLIB is installed
*** but not in the same location as pkg-config add the location of the file
*** glib-2.0.pc to the environment variable PKG_CONFIG_PATH.
I had to add:
LDFLAGS="-L/usr/local/lib"
or it wouldn't find the cairo libs.
Also you should add make; sudo make install to that last bit.
thanks for doing all the hard work.
Next step is to give us a step by step for Glade and PyGTK... :)
What about this?
http://gtk-osx.sourceforge.net/
Latest Jpeg library is here:
http://www.ijg.org/files/jpegsrc.v8.tar.gz
Post a Comment