Added os checks and defs

* Added os checks to some lib link deps.
* Moved out common defs to common function.
* Added os def to common function.