It freezes when compiler can't create binary (".o") file wich is opened in another process.
Do in Windows:
check disk for errors + defragmentation (standard OS system tools)
Also check this:
Every file, dir, library, search path ... shouldn't have spaces!! Mingw can not handle this well.
Also mingw installation dir shouldn't have space (e.g "C:\Program Files\mingw" is wrong install dir).
Before build your project, look in windows's Task Manager if there isn't any hanging mingw process (cc1.exe cc1plus.exe collect2.exe). If yes end them, rebuild project!