Bazel shared library does not include all symbols

  android, bazel, c++, cross-compiling, mediapipe

I am trying to build a shared library using bazel (mediapipe) and linking dependencies without sources or headers fails to include the dependency symbols.

Here is sorta psudo code example

cc_binary(
    name = "library.so",
    deps = ["//project:dependency"],
    linkshared = 1,
)

Some other file:

cc_library(
   name = "dependency",
   srcs = ["file.cc"],
   hdrs = ["file.h"]
)

in file.h

class MyClass {
public:
   int abc = 0;
};

Then when I build with Android let’s say

bazel build -c opt --config=android_arm project:framework.so --linkopt="-s"

After I build, the shared library does not contain any symbols from file.h (MyClass) using

nm -D output/framework.so | grep MyClass

Is there a way to do it? I am also new to bazel.

A more defined question is located on mediapipe’s issues page.

https://github.com/google/mediapipe/issues/2032

Source: Windows Questions C++

LEAVE A COMMENT