[cairo] Cairomm link errors

Charlie Kehoe ckehoe at gmail.com
Wed May 2 17:25:52 PDT 2012


Hello,

Apologies if this is the wrong list. I'm having trouble getting cairomm to
link on my Ubuntu machine. Today I installed libcairomm-1.0-dev using
apt-get:

ckehoe at ckehoe-home:~$ aptitude show libcairomm-1.0-dev
Package: libcairomm-1.0-dev
State: installed
Automatically installed: no
Version: 1.10.0-1
Priority: optional
Section: libdevel
Maintainer: Ubuntu Developers <ubuntu-devel-discuss at lists.ubuntu.com>
Uncompressed Size: 618 k
Depends: libcairomm-1.0-1 (= 1.10.0-1), libcairo2-dev (>= 1.10.0),
         libsigc++-2.0-dev
Suggests: libcairomm-1.0-doc
Description: C++ wrappers for Cairo (development files)
 cairomm provides C++ bindings for the Cairo graphics library, a
multi-platform
 library providing anti-aliased vector-based rendering for multiple target
 backends.

 This package contains the development libraries and header files needed by
C++
 programs that want to compile with Cairo. files and examples.
Homepage: http://cairographics.org/cairomm/

I tried to compile a one-page example program that had worked fine under
Fink in MacOS 10.6, and got a bunch of linker errors. Here is a snippet
from a different program (one of the cairomm examples) that illustrates the
problem:

// test.cc

#include <cairommconfig.h>
#include <cairomm/surface.h>

int main()
{
  Cairo::RefPtr<Cairo::ImageSurface> surface =
    Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 600, 400);
  return 0;
}

I'm using pkg-config to set up the compiler flags:

ckehoe at ckehoe-home:~$ pkg-config --cflags --libs cairomm-1.0
-pthread -I/usr/include/cairo -I/usr/include/glib-2.0
-I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1
-I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/cairomm-1.0
-I/usr/lib/cairomm-1.0/include -I/usr/include/sigc++-2.0
-I/usr/lib/sigc++-2.0/include  -lcairomm-1.0 -lcairo -lsigc-2.0

The includes work fine, but the linker cannot find one of the symbols:

ckehoe at ckehoe-home:~$ g++ `pkg-config --cflags --libs cairomm-1.0` test.cc
-o test
/tmp/cciLT3Ew.o: In function `main':
test.cc:(.text+0x31): undefined reference to
`Cairo::ImageSurface::create(Cairo::Format, int, int)'
collect2: ld returned 1 exit status

So I went digging. ld does seem to be finding the libcairomm library:

ckehoe at ckehoe-home:~$ g++ `pkg-config --cflags --libs cairomm-1.0` test.cc
-o test -Wl,-t,--verbose | grep libcairomm
/attempt to open /usr/lib/gcc/i686-linux-gnu/4.6.1/libcairomm-1.0.so failed
attempt to open /usr/lib/gcc/i686-linux-gnu/4.6.1/libcairomm-1.0.a failed
attempt to open /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/
libcairomm-1.0.so failed
attempt to open
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/libcairomm-1.0.a
failed
*attempt to open /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../../lib/
libcairomm-1.0.so succeeded*
*-lcairomm-1.0 (/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../../lib/
libcairomm-1.0.so)*
tmp/ccciO9t8.o: In function `main':
test.cc:(.text+0x31): undefined reference to
`Cairo::ImageSurface::create(Cairo::Format, int, int)'
/usr/bin/ld: link errors found, deleting executable `test'
collect2: ld returned 1 exit status

And the missing symbol does appear to be in the library:

ckehoe at ckehoe-home:~$ objdump -TC
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../../lib/libcairomm-1.0.so | grep
'Cairo::ImageSurface::create(Cairo::Format, int, int)'
00018dd0 g    DF .text 000000c2  Base
 Cairo::ImageSurface::create(Cairo::Format, int, int)

Similar errors occur when I try to compile the examples
in /usr/share/doc/libcairomm-1.0-dev/examples. The readme provides this
familiar-looking compile command:

g++ `pkg-config --cflags --libs cairomm-1.0` main.cc

What am I missing here?

Thanks in advance for your help.

- Charlie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120502/94549e68/attachment.html>


More information about the cairo mailing list