Apex integration

This pull request:

 - ports the build system for APEX to Windows, 
 - fixes compilation and linker problems for MSVC,
 - fixis some whitespace issues (tabs --> spaces)