Compilation fixes for Visual Studio 2012

Additional preprocessor checks added
Supplied required libraries
General fixes