Or does it just make more sense to leave the optimization until you use the library, or is it when you link the library you are already past the point where 开发者_开发知识库the compiler can optimize the library?
Code optimization happens primarily at compile time. So if you want your static library optimized, you need to do that when you build your library.
There are some optimizations that can happen at link time (although I'm not sure if the GNU linker implements them). But they are additional optimizations, so even if you wanted to use them, you would still want to compile time optimization.
If you want the code in the library optimised, you have to provide the optimisation flags when you compile the library, not when you link with it.
精彩评论