Linux and Mingw fixes for windows branch

These patches include mostly build fixes for mingw and a couple for linux. I put the EngineDialog patch last as I don't imagine you'll apply that if you have conflicting work but I have updated it to include the few changes in that file since the patch I previously sent you was generated.