研究了一天,原来是少看了几个字符,状态,位置太重要了
It sounds like you want to build a fully statically linked library. This can be done in Bazel by building the library using cc_binary with the linkshared attribute set to True. According to the documentation you also have to name your library libfoo.so or similar.
What enables the static library here is cc_binary's linkstatic attributes behavior. When True, which is the default, all dependencies that can be linked statically into the binary will be. Note that linkstatic does NOT behave the same on cc_library, see the documentation.
So, basically you want something like this in your BUILD file
cc_binary(
name = "libfoo.so",
srcs = [...],
hdrs = [...],
linkshared = 1,
#linkstatic = 1 # This is the default, you don't need to add this.
)
Good luck!
本文详细介绍了如何使用Bazel构建完全静态链接的库。通过设置cc_binary的linkshared属性为True,并确保库命名为libfoo.so,可以实现依赖项的静态链接。注意,linkstatic属性默认为True,会自动链接所有可静态链接的依赖。
1960

被折叠的 条评论
为什么被折叠?



