If cairo-xlib.h is included in a C++ source file, the compiler will mangle its symbols. Since the symbols in libcairo.so aren't mangled (at least on my system), this causes problems. In particular, mozilla-firefox failed to run because of that. This problem has been addressed in cairo but (apparently) after version 0.3.0. Test programme and patch for 0.3.0 follow. Reproducible: Always Steps to Reproduce: 1. g++ -lcairo -I/usr/include/cairo -o cairo-xlib-test cairo-xlib-test.cc Actual Results: /tmp/ccQD4VHq.o(.text+0x63): In function `main': /home/estar/cairo-xlib-test.cc:8: undefined reference to `cairo_set_target_drawable(_cairo*, _XDisplay*, unsigned long)' collect2: ld returned 1 exit status Expected Results: Test programme should have been linked. $ g++ --version g++ (GCC) 3.4.3-20050110 (Gentoo Hardened Linux 3.4.3.20050110-r1, ssp-3.4.3.20050110-0, pie-8.7.7) <snip> $ qpkg -nc -q -v cairo | head -n 1 x11-libs/cairo-0.3.0-r1 * $ pkg-config --modversion cairo 0.3.0
Created attachment 54931 [details] Test programme. Compile with -lcairo -I/usr/include/cairo.
Created attachment 54932 [details, diff] Patch for cairo-xlib.h. The problem has already been addressed in a similar way in cairo's CVS.
Although I agree that this header definitely doesn't have the necessary foo to handle C++ stuff, Checking out the latest cairo CVS (http://cvs.cairographics.org/cairo/src/cairo-xlib.h) doesn't seem to have the fix you refer to. As to mozilla-firefox, can you please post details of the failures you're having with it?
(I'm not the orginal submitter but I had the problem on various archs both x86 and ppc) Please look at http://cvs.cairographics.org/cairo/src/cairo-xlib.h?r1=1.6&r2=1.7 CAIRO_BEGIN_DECLS CAIRO_END_DECLS have been added and are defined in cairo.h as : #ifdef __cplusplus # define CAIRO_BEGIN_DECLS extern "C" { # define CAIRO_END_DECLS } #else # define CAIRO_BEGIN_DECLS # define CAIRO_END_DECLS #endif To highlight the problem : $ ldd -r /usr/lib/MozillaFirefox/components/libgklayout.so [...] undefined symbol: _Z25cairo_set_target_drawableP6_cairoP9_XDisplaym (/usr/lib/MozillaFirefox/components/libgklayout.so) $ readelf -s /usr/lib/libcairo.so.1.0.0 | grep drawable 194: 000224e4 200 FUNC GLOBAL DEFAULT 9 cairo_set_target_drawable libcairo.so.1.0.0 functions names are standard C, but are C++ mangled in /usr/lib/MozillaFirefox/components/libgklayout.so Because firefox was segfaulting in some configurations and if though it was related to hardened toolchain, I've put some more details in bug #83511
I was referring to the code posted by Olivier. The Firefox problem is identical with his; for a description, see bug #86785 (in particular http://bugs.gentoo.org/show_bug.cgi?id=86785#c8).
Created attachment 55723 [details, diff] cairo-xlib.h patch Same patch to the header, just reformated slightly to be nicer to apply in the ebuild.
Created attachment 55724 [details, diff] Diff to the current 0.3.0-r1 cairo ebuild Here's a diff to the current 0.3.0-r1 ebuild to make it apply the cairo-xlib.h patch. Apply this diff, and drop the cairo-xlib.h patch into the files/ dir, and install it. Please report back if this fixes your mozilla-firefox problems. If so, i'll get this commited as 0.3.0-r2 for people. Thanks.
Applied, dropped, installed, fixed. Thank you.
Ok, i've just commited this as 0.3.0-r2. Thanks for the bug report. Marking FIXED.