MinGW fixes and warning reduction

Hi Qb, here are some minor fixes to fix MinGW compilation. I changed the ADD_DEFINITIONS in so that -fpermissive would only be used by the C++ compiler (g++ in this case) gcc spams a warning message when you use -fpermissive. Added an ifndef to avoid redefining strncasecmp, and there were some missing includes (cstring for memset, cmath for abs and sqrt, cstdio for fopen/close/etc.).