I try to build a dynamic library for some class defined in a BAZEL project with cc_shared_library, but the constructed dynamic library does not have symbol information for member functions returning pointer member variables.
The definition of some classes is as follows.
class TestClass {
public:
const TypeA& member_a() const { return *(CHECK_NOTNULL(member_a_)); }
TypeA* mutable_member_a() { return (CHECK_NOTNULL(member_a_.get)).get(); }
// ...
// There are some public interfaces for other members similar to the above here.
private:
std::unique_ptr<TypeA> member_a_;
// ...
// There are many other class object member similar to member_a_ here.
};
The BUILD file is as follows.
cc_library(
name = "test_class",
srcs = ["test_class.cc"],
hdrs = ["test_class.h"],
deps = ["//path/to:type_a", "//path/to:other_type"],
)
(In other BUILD file)
cc_shared_library(
name = "_test_class",
deps = ["//path/to:test_class"],
)
After I built _test_class
target, I use nm -A bazel-bin/path/to/lib_test_class.so
. I can not find symbol information similar to mutable_member_a()
, but I can find symbol for member_a()
. I really hope to understand why symbols like mutable_member_a()
are not present and how to make the dynamic library contain these symbols.
This project has a main entry function which uses TestClass objects. I build executable file which dynamically links to ‘bazel-bin/path/to/lib_test_class.so’. I can find weak symbols of mutable_member_a()
of TestClass, which is so weird. Here is some other BUILD information.