SWT in Eclipse 3.1 relies on Cairo library to do advanced drawing, such as paths, antialiasing, transparency. It relies on swt-cairo library which is loaded by the org.eclipse.swt.internal.cairo.Cairo class. On my system I have cairo installed, as it can be seen from the following output: $ qpkg -l x11-libs/cairo x11-libs/cairo-0.1.23-r1 * CONTENTS: /usr /usr/lib /usr/lib/libcairo.la /usr/lib/pkgconfig /usr/lib/pkgconfig/cairo.pc /usr/lib/libcairo.a /usr/lib/libcairo.so.1.0.0 /usr/include /usr/include/cairo-features.h /usr/include/cairo.h /usr/lib/libcairo.so -> libcairo.so.1.0.0 1103690413 /usr/lib/libcairo.so.1 -> libcairo.so.1.0.0 1103690413 Unfortunately, when trying to execute code that uses cairo (such as http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet10.java?rev=HEAD&content-type=text/vnd.viewcvs-markup) I get an error message: Unhandled event loop exception Reason: Unable to load graphics library [Cairo is required] (java.lang.UnsatisfiedLinkError: no swt-cairo-gtk-3138 in java.library.path) Reproducible: Always Steps to Reproduce: 1. Install dev-util/eclipse-skd version 3.1 2. Creaet a new project and use the code from http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet10.java?rev=HEAD&content-type=text/vnd.viewcvs-markup 3. Try running the code Actual Results: Unhandled event loop exception Reason: Unable to load graphics library [Cairo is required] (java.lang.UnsatisfiedLinkError: no swt-cairo-gtk-3138 in java.library.path) Expected Results: Something close to what is shown here http://download.eclipse.org/eclipse/downloads/drops/S-3.1M5a-200502191500/images/advanced_gc.jpg $ emerge info Portage 2.0.51.19 (default-linux/x86/2005.0/2.4, gcc-3.3.5-20050130, glibc-2.3.4.20041102-r1, 2.4.28 i686) ================================================================= System uname: 2.4.28 i686 Intel(R) Pentium(R) 4 CPU 2.53GHz Gentoo Base System version 1.6.12 Python: dev-lang/python-2.3.5 [2.3.5 (#1, May 6 2005, 10:41:56)] dev-lang/python: 2.3.5 sys-apps/sandbox: [Not Present] sys-devel/autoconf: 2.59-r6, 2.13 sys-devel/automake: 1.7.9-r1, 1.8.5-r3, 1.5, 1.4_p6, 1.6.3, 1.9.5 sys-devel/binutils: 2.15.92.0.2-r10 sys-devel/libtool: 1.5.16 virtual/os-headers: 2.4.22-r1 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CFLAGS="-march=pentium3 -O2 -pipe -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-O2 -mcpu=i686 -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs autoconfig ccache distlocks fixpackages sandbox sfperms strict" GENTOO_MIRRORS="rsync://mirrors.tds.net/gentoo http://mirrors.tds.net/gentoo ftp://mirrors.tds.net/gentoo ftp://gentoo.ccccom.com" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="x86 X alsa amp apm avi berkdb bitmap-fonts cdr crypt cups curl dvd eds emboss encode esd fam flac foomaticdb fortran gd gdbm gif gnome gphoto2 gpm gtk gtk2 imagemagick imap imlib ipv6 java jpeg junit libg++ libwww maildir mikmod mmx motif mozcalendar mozilla mozsvg mp3 mpeg mysql ncurses nls ogg opengl oss pam pdflib perl png python quicktime readline samba sasl sdl slang spell sse ssl svg svga tcltk tcpd tetex tiff truetype truetype-fonts type1-fonts usb vorbis xine xml2 xmms xv zlib userland_GNU kernel_linux elibc_glibc" Unset: ASFLAGS, CBUILD, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS
Note that SWT 3.1 requires cairo 0.4.0 and will not work with 0.1.23 or 0.5.0+.
Good point about Cairo version 0.4 needed for Eclipse 3.1. With 0.1.23 a binary install from eclipse.org did not work too well, though did not break. After installing Cairo 0.4 everything works, with a binary install, beautifully. This probably means that cairo-0.4 needs to become a dependecy for Eclipse 3.1
Eclipse 3.1 comes with a pre-built libcairo.so.1 file in the root of the install, placing this directory on your LD_LIBRARY_PATH will allow it to be used and not mess up any system-installed cairo. One option for the gentoo packaging would be to do something similar -- compile and install cairo 0.4.0 in a special place for Eclipse.
We will not support Cairo for Eclipse SDK 3.1. The API 3.1 is coded against is Cairo 0.4.0. This will change in the not-so-distant future. This, together with the fact that the Eclipse SDK itself does not depend on Cairo, makes it a rather dubious proposition to add support for Cairo; it will only cause fear, uncertainly and doubt about whether you can rely on it. The road ahead for Cairo users is swt-3.1. We'll add support for Cairo to this library, so if you install it, add rather have your SWT apps link against this than the SWT provided by eclipse itself, you will be safe. Please install dev-java/swt-3.1, run your applications against that, and reopen the bug if that fails for you. We certainly want to support Cairo for SWT, but not via our Eclipse SDK package.