Win mingw32 fixes (fix build on mingw32)

This fixes one issue with the gyp build using `.lib` in library names which AFAIK should not be necessary since gyp should be correcting the naming (can someone using the MS compiler check me on this?)

Also make threadlocal on GCC work and fix the CRT assert to make the debug build work.