Several fixes for cross-compilation (MingW).