Why do I get errors when I try to build, when rebuild works fine?

Ok, I’ve solved it. The problem was with the paths to include headers and libraries from the Windows SDK… in my case it wasn’t working properly.

I installed Windows SDK 8 and added the paths in project properties: