Fix compilation when Cairo is not present

This also fixes one warning about including windows.h before winsock2.h when compiling with mingw.