g++ partial linking instead of archives?

后端 未结 2 890
梦如初夏
梦如初夏 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:49

    The other time that you want to use ld -r to do a partial link is if you have some object files that contain static initialisation that are required to provide certain functionality but that is never called directly by any of the code.

    If you'd like I can write up a document that showcases how this works and why it works!

    (see run time C++ class registration for example, it uses a static register function that registers itself in a registry, which can then be used to create and return a Base* with polymorphic behaviour since it created a new object that was inherited from Base. See C++ runtime knowledge of classes which is an answer to a question I asked.)

提交回复
热议问题