title: Static libpixman-1.a Linking Errors on Windows
body: <p>I am trying to build a static <a href="https://www.cairographics.org/" rel="nofollow noreferrer">Cairo library</a> on Windows under <a href="https://www.msys2.org/" rel="nofollow noreferrer">MSYS2/MinGW-w64</a> &amp; am having trouble linking to <code>libpixman-1.a</code> static library. The linker errors are as follows:</p>
  
  <pre><code>...
  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'
  </code></pre>
  
  <p>The issue appears to be directly related to the <code>libpixman-1.a</code> library itself. I've searched the web but have not found any issues concerning the undefined references mentioned above. I have sent messages to <a href="https://lists.cairographics.org/cgi-bin/mailman/listinfo/cairo" rel="nofollow noreferrer">Cairo</a> &amp; <a href="https://lists.freedesktop.org/mailman/listinfo/pixman" rel="nofollow noreferrer">Pixman</a> mailing lists, as the two projects appear to be related. I have also contacted the Cairo project on <a href="https://webchat.freenode.net/?channels=#cairo" rel="nofollow noreferrer">their IRC channel</a>. I am currently still waiting on responses. I have also sent an issue report to the MSYS2 project.</p>
  
  <p>The following is the configuration command that I used for building the static <code>libpixman-1.a</code> library (which uses the <a href="https://mesonbuild.com/" rel="nofollow noreferrer">Meson Build system</a> of which I am not very familiar):</p>
  
  <pre><code>meson --buildtype plain -Ddefault_library=static -Dgtk=disabled ../pixman-0.38.4
  </code></pre>
  
  <p>MSYS2 uses a port of <a href="https://wiki.archlinux.org/index.php/Arch_Build_System" rel="nofollow noreferrer">Arch Linux's build system</a> for its package management. The original build configuration &amp; patches for the pixman library can be <a href="https://github.com/msys2/MINGW-packages/blob/b80713152cedea8f421b4428c973b9f584734f63/mingw-w64-pixman" rel="nofollow noreferrer">found here</a>.</p>
  
  <p>Next is the configuration that I am trying to use for building a static cairo library:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The original build configuration &amp; patches for the cairo library can be <a href="https://github.com/msys2/MINGW-packages/blob/b80713152cedea8f421b4428c973b9f584734f63/mingw-w64-cairo" rel="nofollow noreferrer">found here</a>.</p>
  
  <p>Originally I was also getting undefined references for <a href="https://www.freedesktop.org/wiki/Software/HarfBuzz/" rel="nofollow noreferrer">harfbuzz</a> &amp; <a href="http://www.bzip.org/" rel="nofollow noreferrer">bzip2</a> libraries. But adding explicit links to them (<code>LIBS="-lharfbuzz -lbz2"</code>) solved those issues. Since the linker is already trying to link to <code>libpixman-1.a</code> library, including it in the <code>LIBS</code> variable does not change anything.  And because there is no shared pixman library on my system, using an explicit static link (<code>-l:libpixman-1.a</code>) doesn't help either. I believe I attempted that already, but will try again, just in case.</p>
  
  <p><strong>Edit:</strong> I found the options <code>-Dmmx=disabled -Dsse2=disabled -Dssse3=disabled</code> for building the pixman library &amp; going to try rebuilding. Perhaps those options are only available in the shared version of the library?</p>