Fix various issues when building on Windows (dependencies, static library support)