3
votes

I'm trying to build cairo on Windows using MinGW (and MSYS). I am following the instrucions on Compiling GTK+ 2.16.4 for Windows, except that I'm using the latest versions whenever possible, i.e:

  • zlib-1.2.3
  • libpng-1.2.42
  • pixman-0.17.4
  • cairo-1.8.8

This works pretty well up until when I try to build the actual cairo. The configuration succeeds, but during make cairo seems to have problems linking to my build of libpng. After a little while I get a long list of errors such as this:

.libs/cairo-png.o: In function `png_simple_error_callback':
/home/user/cairo-1.8.8/src/cairo-png.c:95: undefined reference to `png_get_error_ptr'
.libs/cairo-png.o: In function `png_simple_warning_callback':
/home/user/cairo-1.8.8/src/cairo-png.c:112: undefined reference to `png_get_error_ptr'

...

.libs/cairo-png.o: In function `stream_read_func':
/home/user/cairo-1.8.8/src/cairo-png.c:686: undefined reference to `png_error'
collect2: ld returned 1 exit status
make[3]: *** [libcairo.la] Error 1
make[3]: Leaving directory `/home/user/cairo-1.8.8/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/user/cairo-1.8.8/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/user/cairo-1.8.8'
make: *** [all] Error 2

I have tried using an older version of libpng (1.2.40, the version being distributed by The GTK+ Project), with the same result. When I run "pkg-config -cflags -libs libpng" I get "-IC:/MinGW/include/libpng12 -LC:/MinGW/lib -lpng12", which seems correct. I'm sure I'm making some stupid mistake, but I cannot tell what it is.

2
Well, it turns out that my build of libpng was broken. When I compared it to a build that I had done a while ago on a different machine I noticed that 'libpng12.dll.a' was much too small (<1kb). I couldn't figure out a way to make it work so I just copied the version from the other machine and it fixed my problems with cairo. This I not very satisfying, but since I already spent more time on this than I should have, I'll just move on right now. If anybody runs into the same problem, they can use the same approach and get a working version from GnuWin (sourceforge.net/projects/gnuwin32).kloffy
Quick follow-up: The same thing happened with another library (libcroco), so I think something is wrong with my MinGW/MSYS. The builds complete without error message, but the *.dll.a files end up smaller than they should be and whenever another program tries to use those libraries it fails during linking. I don't know what is wrong, I've used MinGW before and never had that problem. It could have something to do with me using Windows 7 (as opposed to Windows XP, which I used previously), but I haven't found anything online saying this could lead to problems...kloffy

2 Answers

2
votes

Apparently this is a known issue. I don't know how managed to miss it, given that it is even mentioned in the blog that I was following (I think it's safe to assume that this also applies to Windows 7, given that I tried the third suggestion and it fixed my problem):

Now, let's install MinGW. Note that MinGW doesn't run smoothly on Windows Vista because of weird filesystem restrictions. The workaround is

  • to install MinGW on FAT filesystem,
  • to work in the safe mode, or
  • to use MinGW Portable which is said to be working well.
2
votes

I noticed that 'libpng12.dll.a' was much too small (<1kb).

It is so due to incorrect symbols in libpng.vers (symbols have extra _ at beginning). After libpng build I removed extra _ and recreated libpng12.dll.a manually - size is OK now. But... The correct import library doesn't resolve your (and my) problem.