bazel 編譯動態庫,供ctypes調用

研究了一天,原來是少看了幾個字符,狀態,位置太重要了

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!

https://stackoverflow.com/questions/54951531/building-libraries-with-bazel-and-hardcoding-dependencies-into-them

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章