Fix linux and windows build issues.

- Linux makefile overrides and removes the optimization flags.
- Old linux gcc doesn't understand lambdas.
- MSVC doesn't like extern and explicit instantiation in same file.