Search code examples
ccairopixman

Static libpixman-1.a Linking Errors on Windows


I am trying to build a static Cairo library on Windows under MSYS2/MinGW-w64 & am having trouble linking to libpixman-1.a static library. The linker errors are as follows:

...
libtool: link: ranlib .libs/libcairoboilerplate.a
C:/Development/MSYS2/mingw32/lib/libpixman-1.a(pixman-x86.c.obj):(.text+0x204): undefined reference to `_pixman_implementation_create_mmx'
C:/Development/MSYS2/mingw32/lib/libpixman-1.a(pixman-x86.c.obj):(.text+0x213): undefined reference to `_pixman_implementation_create_sse2'
C:/Development/MSYS2/mingw32/lib/libpixman-1.a(pixman-x86.c.obj):(.text+0x1b8): undefined reference to `_pixman_implementation_create_ssse3'

The issue appears to be directly related to the libpixman-1.a library itself. I've searched the web but have not found any issues concerning the undefined references mentioned above. I have sent messages to Cairo & Pixman mailing lists, as the two projects appear to be related. I have also contacted the Cairo project on their IRC channel. I am currently still waiting on responses. I have also sent an issue report to the MSYS2 project.

The following is the configuration command that I used for building the static libpixman-1.a library (which uses the Meson Build system of which I am not very familiar):

meson --buildtype plain -Ddefault_library=static -Dgtk=disabled ../pixman-0.38.4

MSYS2 uses a port of Arch Linux's build system for its package management. The original build configuration & patches for the pixman library can be found here.

Next is the configuration that I am trying to use for building a static cairo library:

CFLAGS+=" -Wno-implicit-function-declaration"
../cairo-1.16.0/configure --prefix=/mingw32 \
    --build=x86_64-pc-mingw32 --host=x86_64-pc-mingw32 --enable-win32 --enable-win32-font \
    --enable-png --enable-shared=no --enable-static --enable-gobject --enable-tee \
    --disable-xlib --disable-xcb --enable-fc --enable-ft --disable-silent-rules \
    LIBS="-lharfbuzz -lbz2" ac_cv_prog_GS=${MINGW_PREFIX}/bin/gsc

The original build configuration & patches for the cairo library can be found here.

Originally I was also getting undefined references for harfbuzz & bzip2 libraries. But adding explicit links to them (LIBS="-lharfbuzz -lbz2") solved those issues. Since the linker is already trying to link to libpixman-1.a library, including it in the LIBS variable does not change anything. And because there is no shared pixman library on my system, using an explicit static link (-l:libpixman-1.a) doesn't help either. I believe I attempted that already, but will try again, just in case.

Edit: I found the options -Dmmx=disabled -Dsse2=disabled -Dssse3=disabled for building the pixman library & going to try rebuilding. Perhaps those options are only available in the shared version of the library?


Solution

  • Building pixman library with MMX, SSE2, & SSSE3 optimizations disabled fixes the problem & allows me to build static only cairo library:

    meson --buildtype plain -Ddefault_library=static -Dgtk=disabled -Dmmx=disabled -Dsse2=disabled \
        -Dssse3=disabled ../pixman-0.38.4