g++ partial linking instead of archives?

后端 未结 2 896
梦如初夏
梦如初夏 2020-12-10 05:58

I\'m pretty new to the C++ build flow, and I\'m thinking of switching to use partial linking for my libraries instead of creating ar archives. I\'m hoping to re

2条回答
  •  甜味超标
    2020-12-10 06:48

    You lose an important effect of having the object files in an ar archive, which is that only the referenced objects will be linked in.

    If you have both foo.o with the symbol foo and bar.o with the symbol bar in an ar archive, and only reference the foo symbol, only foo.o would be linked in. If you instead do a partial link, the contents of both will end up in the executable, even if bar is never referenced anywhere.

    You could also try a faster linker, like gold.

提交回复
热议问题