Two types of build configurations

  1. debug used for developing the applications
  2. release to create production ready build.

Debug build

  • -ggdb option is used to enable debug build.

Release build

  • -O2 -DNDEBUG is used to enable release bulids.
  • -O# flag is used for optimizations.
    • -O1 is for debug level optimization. this is the default value.
    • -O2 is for release level optimizations.
    • -O3 adds additional optimizations that may or may not perform better than -O2.

Note

-O2 is alphabet “O” not “0”.

References

  1. https://www.learncpp.com/cpp-tutorial/configuring-your-compiler-build-configurations/