gpt4 book ai didi

c++ - bazel alwayslink = true 是什么意思?

转载 作者:行者123 更新时间:2023-11-30 05:04:51 38 4
gpt4 key购买 nike

我是 bazel 的新手。这是 bazel 文档中的解释:

https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library.alwayslink

alwayslink

Boolean; optional; nonconfigurable; default is 0

If 1, any binary that depends (directly or indirectly) on this C++ library will link in all the object files for the files listed in srcs, even if some contain no symbols referenced by the binary. This is useful if your code isn't explicitly called by code in the binary, e.g., if your code registers to receive some callback provided by some service.

我不太明白最后一句话:例如,如果您的代码注册以接收某些服务提供的回调。 谁能举个例子?谢谢!

最佳答案

e.g., if your code registers to receive some callback provided by some service.

AIUI,cc_binary 构建共享库/DLL 时就是这种情况。您需要链接器保留所有符号,即使未使用也是如此,因为在运行时加载 .so/.dll 的另一个二进制文件可能需要这些符号。

关于c++ - bazel alwayslink = true 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48653517/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com