buildfix on MSYS

Not meant to be merged, but it shows what is needed to build on windows/msys. Maybe someone else can incorporate the changes correctly.