Make building work with Mingw

Applied changes by @imbaczek