I am new to bazel. I tried the tutorial below https://docs.bazel.build/versions/master/tutorial/cpp.html#use-multiple-packages
And to create a shared library, I added 'linkstatic = False' in cc_binary,
So BUILD file is
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
cc_library(
name = "hello-greet",
srcs = ["hello-greet.cc"],
hdrs = ["hello-greet.h"],
)
cc_binary(
name = "hello-world",
srcs = ["hello-world.cc"],
deps = [
":hello-greet",
"//lib:hello-time"
],
linkstatic = False,
)
and after build, I confirmed that 'libhello-greet.so' was created under the bazel-bin directory. However, if I check the hello-world executable with ldd, it is as follows.
$ ldd hello-world
~snip~
libmain_Slibhello-greet.so => /home/foo/.cache/bazel/_bazel_wrs/8e7a6d8989ff6d697373ddbabde23fa3/execroot/__main__/bazel-out/k8-fastbuild/bin/main/./../_solib_k8/libmain_Slibhello-greet 0x00007f2706f84000)
liblib_Slibhello-time.so => /home/foo/.cache/bazel/_bazel_wrs/8e7a6d8989ff6d697373ddbabde23fa3/execroot/__main__/bazel-out/k8-fastbuild/bin/main/./../_solib_k8/liblib_Slibhello-time.so 0x00007f2706f81000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2706462000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2706071000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2706da1000)
Why hello-world linking the library(libmain_Slibhello-greet.s) in the cache directory instead of linking the locally generated libhello-greet.so? How do I change it link to libhello-greet.so?