Optimization and flags for making a static library with g++

前端 未结 5 1644
一整个雨季
一整个雨季 2021-01-30 01:53

I am just starting with g++ compiler on Linux and got some questions on the compiler flags. Here are they

Optimizations

I read about optimizatio

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 02:23

    The rule of thumb:

    When you need to debug, use -O0 (and -g to generate debugging symbols.)

    When you are preparing to ship it, use -O2.

    When you use gentoo, use -O3...!

    When you need to put it on an embedded system, use -Os (optimize for size, not for efficiency.)

提交回复
热议问题