[GRASS-dev] GRASS 7: cairo compilation problem

Hi,

I have problems to compile cairo after a distro upgrade:

[neteler@north cairodriver]$ make
gcc -shared -o /home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib/libgrass_cairodriver.7.0.svn.so
-L/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
-L/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
-Wl,--no-undefined -Wl,--export-dynamic -L/usr/lib64
-Wl,-rpath-link,/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
  OBJ.x86_64-unknown-linux-gnu/Box.o
OBJ.x86_64-unknown-linux-gnu/Color.o
OBJ.x86_64-unknown-linux-gnu/Draw_bitmap.o
OBJ.x86_64-unknown-linux-gnu/Draw.o
OBJ.x86_64-unknown-linux-gnu/Driver.o
OBJ.x86_64-unknown-linux-gnu/Erase.o
OBJ.x86_64-unknown-linux-gnu/Graph.o
OBJ.x86_64-unknown-linux-gnu/Line_width.o
OBJ.x86_64-unknown-linux-gnu/Raster.o
OBJ.x86_64-unknown-linux-gnu/read_bmp.o
OBJ.x86_64-unknown-linux-gnu/read.o
OBJ.x86_64-unknown-linux-gnu/read_ppm.o
OBJ.x86_64-unknown-linux-gnu/read_xid.o
OBJ.x86_64-unknown-linux-gnu/Set_window.o
OBJ.x86_64-unknown-linux-gnu/Text.o
OBJ.x86_64-unknown-linux-gnu/write_bmp.o
OBJ.x86_64-unknown-linux-gnu/write.o
OBJ.x86_64-unknown-linux-gnu/write_ppm.o
OBJ.x86_64-unknown-linux-gnu/write_xid.o -lgrass_driver.7.0.svn
-lgrass_gis.7.0.svn -lfreetype -lXrender -lcairo -lX11
-L/usr/lib64 -lSM -lICE -lX11 -lm
OBJ.x86_64-unknown-linux-gnu/Text.o: In function `fc_init':
/home/neteler/grass70/lib/cairodriver/Text.c:180: undefined reference
to `FcInit'
OBJ.x86_64-unknown-linux-gnu/Text.o: In function `set_font_fc':
/home/neteler/grass70/lib/cairodriver/Text.c:198: undefined reference
to `FcNameParse'
/home/neteler/grass70/lib/cairodriver/Text.c:199: undefined reference
to `FcDefaultSubstitute'
/home/neteler/grass70/lib/cairodriver/Text.c:200: undefined reference
to `FcConfigGetCurrent'
/home/neteler/grass70/lib/cairodriver/Text.c:200: undefined reference
to `FcConfigSubstitute'
/home/neteler/grass70/lib/cairodriver/Text.c:201: undefined reference
to `FcConfigGetCurrent'
/home/neteler/grass70/lib/cairodriver/Text.c:201: undefined reference
to `FcFontMatch'
OBJ.x86_64-unknown-linux-gnu/Text.o: In function `font_list_fc':
/home/neteler/grass70/lib/cairodriver/Text.c:217: undefined reference
to `FcPatternCreate'
/home/neteler/grass70/lib/cairodriver/Text.c:218: undefined reference
to `FcObjectSetBuild'
/home/neteler/grass70/lib/cairodriver/Text.c:219: undefined reference
to `FcFontList'
/home/neteler/grass70/lib/cairodriver/Text.c:228: undefined reference
to `FcPatternGetString'
/home/neteler/grass70/lib/cairodriver/Text.c:229: undefined reference
to `FcPatternGetString'
/home/neteler/grass70/lib/cairodriver/Text.c:240: undefined reference
to `FcObjectSetDestroy'
/home/neteler/grass70/lib/cairodriver/Text.c:241: undefined reference
to `FcPatternDestroy'
/home/neteler/grass70/lib/cairodriver/Text.c:242: undefined reference
to `FcFontSetDestroy'
collect2: ld returned 1 exit status
make: *** [/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib/libgrass_cairodriver.7.0.svn.so]
Error 1

In Text.c, I see

#if CAIRO_HAS_FT_FONT
#include <cairo-ft.h>
#include <fontconfig/fontconfig.h>
#endif

but

[neteler@north cairodriver]$ grep CAIRO_HAS_FT_FONT ../../include/config.h
[neteler@north cairodriver]$ grep CAIRO_HAS_FT_FONT *
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT

and

ls -l /usr/include/fontconfig/fontconfig.h
-rw-r--r-- 1 root root 23426 2010-01-18 17:58
/usr/include/fontconfig/fontconfig.h

So I wonder how this should work but I may have overseen a detail.

Markus

Markus Neteler wrote:

I have problems to compile cairo after a distro upgrade:

You did run "make distclean" then re-configure, right?

[neteler@north cairodriver]$ make
gcc -shared -o /home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib/libgrass_cairodriver.7.0.svn.so
-L/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
-L/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
-Wl,--no-undefined -Wl,--export-dynamic -L/usr/lib64
-Wl,-rpath-link,/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib

-lgrass_driver.7.0.svn
-lgrass_gis.7.0.svn -lfreetype -lXrender -lcairo -lX11
-L/usr/lib64 -lSM -lICE -lX11 -lm
OBJ.x86_64-unknown-linux-gnu/Text.o: In function `fc_init':
/home/neteler/grass70/lib/cairodriver/Text.c:180: undefined reference
to `FcInit'

Fc = Fontconfig.

In Text.c, I see

#if CAIRO_HAS_FT_FONT
#include <cairo-ft.h>
#include <fontconfig/fontconfig.h>
#endif

but

[neteler@north cairodriver]$ grep CAIRO_HAS_FT_FONT ../../include/config.h
[neteler@north cairodriver]$ grep CAIRO_HAS_FT_FONT *
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT

and

ls -l /usr/include/fontconfig/fontconfig.h
-rw-r--r-- 1 root root 23426 2010-01-18 17:58
/usr/include/fontconfig/fontconfig.h

So I wonder how this should work but I may have overseen a detail.

If cairo was built with Fontconfig support, CAIRO_HAS_FT_FONT will be
defined in cairo-features.h. Also, "pkg-config --libs cairo-ft" will
typically output something like "-lcairo -lfreetype -lfontconfig".

The fact that -lfontconfig isn't appearing in the link command
suggests that "pkg-config --libs cairo-ft" isn't mentioning it. But
the undefined symbol errors suggest that CAIRO_HAS_FT_FONT is defined
in cairo-features.h.

IOW, cairo can't make up its mind whether it was built with fontconfig
support or not. Is it possible that you have more than one version,
and it's using the headers from one version and libraries (and
pkg-config data) from another.

Either that, or configure hasn't been re-run and Platform.make still
has the old linker flags for a non-fontconfig version of cairo.

--
Glynn Clements <glynn@gclements.plus.com>

On Fri, Aug 27, 2010 at 7:47 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Markus Neteler wrote:

I have problems to compile cairo after a distro upgrade:

You did run "make distclean" then re-configure, right?

Yes.

[neteler@north cairodriver]$ make
gcc -shared -o /home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib/libgrass_cairodriver.7.0.svn.so
-L/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
-L/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib
-Wl,--no-undefined -Wl,--export-dynamic -L/usr/lib64
-Wl,-rpath-link,/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/lib

-lgrass_driver.7.0.svn
-lgrass_gis.7.0.svn -lfreetype -lXrender -lcairo -lX11
-L/usr/lib64 -lSM -lICE -lX11 -lm
OBJ.x86_64-unknown-linux-gnu/Text.o: In function `fc_init':
/home/neteler/grass70/lib/cairodriver/Text.c:180: undefined reference
to `FcInit'

Fc = Fontconfig.

In Text.c, I see

#if CAIRO_HAS_FT_FONT
#include <cairo-ft.h>
#include <fontconfig/fontconfig.h>
#endif

but

[neteler@north cairodriver]$ grep CAIRO_HAS_FT_FONT ../../include/config.h
[neteler@north cairodriver]$ grep CAIRO_HAS_FT_FONT *
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT
Text.c:#if CAIRO_HAS_FT_FONT

and

ls -l /usr/include/fontconfig/fontconfig.h
-rw-r--r-- 1 root root 23426 2010-01-18 17:58
/usr/include/fontconfig/fontconfig.h

So I wonder how this should work but I may have overseen a detail.

If cairo was built with Fontconfig support, CAIRO_HAS_FT_FONT will be
defined in cairo-features.h.

Yes:

grep FT /usr/include/cairo/cairo-features.h
#define CAIRO_HAS_FT_FONT 1

Also, "pkg-config --libs cairo-ft" will
typically output something like "-lcairo -lfreetype -lfontconfig".

I only get

pkg-config --libs cairo-ft
-lcairo -lfreetype

The fact that -lfontconfig isn't appearing in the link command
suggests that "pkg-config --libs cairo-ft" isn't mentioning it. But
the undefined symbol errors suggest that CAIRO_HAS_FT_FONT is defined
in cairo-features.h.

So some mess here.

IOW, cairo can't make up its mind whether it was built with fontconfig
support or not. Is it possible that you have more than one version,
and it's using the headers from one version and libraries (and
pkg-config data) from another.

rpm -qa | grep 'cairo\|fontconf' | sort
fontconfig-2.8.0-2mdv2010.1
lib64cairo2-1.9.6-3mdv2010.1
lib64cairo-devel-1.9.6-3mdv2010.1
lib64cairomm1.0_1-1.8.4-1mdv2010.1
lib64fontconfig1-2.8.0-2mdv2010.1
lib64fontconfig-devel-2.8.0-2mdv2010.1
libcairo2-1.9.6-3mdv2010.1
libfontconfig1-2.8.0-2mdv2010.1
python-cairo-1.8.8-1mdv2010.1

This looks normal.

ldd /usr/lib64/libcairo.so | grep font
        libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007f41a3f36000)

If I add -lfontconfig in include/Make/Platform.make here:

#cairo
CAIROINC = -I/usr/include/cairo
-I/usr/include/pixman-1 -I/usr/include/freetype2
-I/usr/include/libpng12
CAIROLIB = -lfreetype -lXrender -lcairo -lX11 -lfontconfig
USE_CAIRO = 1
CAIRO_HAS_XRENDER = 1
CAIRO_HAS_XRENDER_SURFACE = 1

then it compiles ok.

As I understand, the pkg-config output here is wrong since it is used:
configure.in:CAIROLIB=`pkg-config --libs $cairo`

Markus

Markus Neteler wrote:

> IOW, cairo can't make up its mind whether it was built with fontconfig
> support or not. Is it possible that you have more than one version,
> and it's using the headers from one version and libraries (and
> pkg-config data) from another.

rpm -qa | grep 'cairo\|fontconf' | sort

lib64cairo2-1.9.6-3mdv2010.1

libcairo2-1.9.6-3mdv2010.1

Is it possible that one of these has FreeType support and the other
doesn't?

As I understand, the pkg-config output here is wrong since it is used:
configure.in:CAIROLIB=`pkg-config --libs $cairo`

Yes.

Also, because of issues with pkg-config (e.g. not existing on
platforms other than Linux), configure also has:

  --with-cairo-includes=DIRS
                          cairo include files are in DIRS
  --with-cairo-libs=DIRS cairo library files are in DIRS
  --with-cairo-ldflags=FLAGS
                          cairo needs FLAGS when linking

So --with-cairo-ldflags=-lfontconfig may be able to work around this.

--
Glynn Clements <glynn@gclements.plus.com>

On Sat, Aug 28, 2010 at 3:06 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Markus Neteler wrote:

> IOW, cairo can't make up its mind whether it was built with fontconfig
> support or not. Is it possible that you have more than one version,
> and it's using the headers from one version and libraries (and
> pkg-config data) from another.

rpm -qa | grep 'cairo\|fontconf' | sort

lib64cairo2-1.9.6-3mdv2010.1

libcairo2-1.9.6-3mdv2010.1

Is it possible that one of these has FreeType support and the other
doesn't?

Both appear to have support:

[neteler@north ~]$ rpm -qil lib64cairo2-1.9.6-3mdv2010.1 | grep 'so.'
/usr/lib64/libcairo-script-interpreter.so.2
/usr/lib64/libcairo-script-interpreter.so.2.10906.0
/usr/lib64/libcairo.so.2
/usr/lib64/libcairo.so.2.10906.0

[neteler@north ~]$ ldd /usr/lib64/libcairo.so.2 | grep 'free\|fontc'
        libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007f3be8b80000)
        libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007f3be88f8000)

[neteler@north ~]$ rpm -qil libcairo2-1.9.6-3mdv2010.1 | grep 'so.'
/usr/lib/libcairo-script-interpreter.so.2
/usr/lib/libcairo-script-interpreter.so.2.10906.0
/usr/lib/libcairo.so.2
/usr/lib/libcairo.so.2.10906.0

[neteler@north ~]$ ldd /usr/lib/libcairo.so.2 | grep 'free\|fontc'
        libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0xf75e7000)
        libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xf7563000)

As I understand, the pkg-config output here is wrong since it is used:
configure.in:CAIROLIB=`pkg-config --libs $cairo`

Yes.

I have opened a bug report in the Mandriva tracker.

Also, because of issues with pkg-config (e.g. not existing on
platforms other than Linux), configure also has:

--with-cairo-includes=DIRS
cairo include files are in DIRS
--with-cairo-libs=DIRS cairo library files are in DIRS
--with-cairo-ldflags=FLAGS
cairo needs FLAGS when linking

So --with-cairo-ldflags=-lfontconfig may be able to work around this.

Yes, this works as workaround, thanks.

Markus