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

前端 未结 5 1579
一整个雨季
一整个雨季 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:40

    The gcc manual list all implied options by every optimization level. At O2, you get things like constant folding, branch prediction and co, which can change significantly the speed of your application, depending on your code. The exact options are version dependent, but they are documented in great detail.

    To build a static library, you use ar as follows:

    ar rc libfoo.a foo.o foo2.o ....
    ranlib libfoo.a
    

    Ranlib is not always necessary, but there is no reason for not using it.

提交回复
热议问题