rule generate so library not work

22 views
Skip to first unread message

zero

unread,
Jun 11, 2022, 2:52:45 AMJun 11
to bazel-discuss
Hi all, I want to generate a so library use below workround, and I found that use just deps will not work?

I use bazel https://github.com/bazelbuild/examples/tree/main/cpp-tutorial/stage3 as an example, modify the "cpp-tutorial/stage3/lib/BUILD"
cc_binary(
name = "libhello-time.so",
srcs = [
"hello-time.h",
"hello-time.cc"
],
linkshared = True,
linkstatic = True,
visibility = ["//main:__pkg__"],
)

it will generate a "libhello-time.so" and work well, but if I use just deps, but not srcs

cc_library(
name = "hello-time-p",
srcs = ["hello-time.cc"],
hdrs = ["hello-time.h"],
visibility = ["//main:__pkg__"],
)

cc_binary(
name = "libhello-time.so",
linkshared = True,
linkstatic = True,
deps = [":hello-time-p"],        #just deps
)

it will generate "libhello-time.so", but "libhello-time.so" seems empty, below is the "nm libhello-time.so" output of "libhello-time.so"

U dyld_stub_binder


My question is, how do I generate the so library file, include other libraries through deps, or I can only generate the so library through srcs


zero

unread,
Jun 11, 2022, 4:32:54 AMJun 11
to bazel-discuss
finnaly I found add "alwayslink = True" to cc_library will work
Reply all
Reply to author
Forward
0 new messages