After much experimenting, I was able to fix the problem.
I reinstalled the windows sdk 7.1, this time I have changed the default path where the installation of sdk takes place. Earlier the sdk was by default getting installed to
C:\Program Files\Microsoft SDKs\Windows\v7.1
but after the installation was complete when I looked in C:\Program Files\Microsoft SDKs , I could not find any windows sdk, because it got installed in C:\Program Files (x86)\Microsoft SDKs\Windows folder instead. So while re-installing the windows sdk I have changed the default path which was pointing to C:\Program Files\ Microsoft SDKs to C:\Program Files (x86)\ Microsoft SDKs and that helped.
Before re-installing windows sdk make sure to uninstall all the visual c++ versions that got installed.
The weak module got installed but with a warning, which didn't cause any problem though. Hope this helps.