bazel 6.5.0 build: failing to link external non-bazel shared library

15 views Asked by At

I am trying to build a shared library using Bazel-6.5.0. The shared library has an external non-Bazel library dependency. After Bazel build I get the new shared library ".so" file. But using ldd I cannot find the external dependency.

The WORKSPACE file looks as follows.

new_local_repository(
name = "pcl",
path = "/usr/",
build_file = "@//pcl:BUILD",
)

the BUILD File of pcl:

cc_library(
name = "pcl",
srcs = glob(["lib/x86_64-linux-gnu/libpcl\*.so\*"]),
hdrs = glob(["include/pcl-1.8/pcl/**/*.h*"]),
includes = ["include/pcl-1.8/"],
deps = [":eigen3"],
visibility = ["//visibility:public"],
linkstatic = 0,
)

The BUILD file:

cc_library(
name = "pcd_handle",
srcs = ["pcd_handle.cpp"],
hdrs = ["pcd_convert_cgo.h"],
deps = ["@pcl//:pcl",],
copts = ["-fPIC"],
visibility = ["//visibility:public"],
linkstatic=0
)

After building the library it creates libpcd_handle.so.

ldd libpcd_handle.so
linux-vdso.so.1 (0x00007fffbb75e000)
libstdc++.so.6 =\> /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f635be89000)
libgcc_s.so.1 =\> /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f635bc71000)
libc.so.6 =\> /lib/x86_64-linux-gnu/libc.so.6 (0x00007f635b880000)
libm.so.6 =\> /lib/x86_64-linux-gnu/libm.so.6 (0x00007f635b4e2000)

Here libpcd_handle.so does not include libpcl**.so. How can I fix the Bazel build?

0

There are 0 answers