Код: Выделить всё
load("//bazel:bundle.bzl", "bundle_cc_hdrs", "bundle_files")
load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external")
cc_library(
name = "diskann_impl",
srcs = [
"xxx/src/*.cpp",
"xxx/src/index.cpp",
],
hdrs = glob([
"xxx/**/*.h",
]),
strip_include_prefix = "xxx/include",
include_prefix = "",
linkopts = [
"-lgomp",
"-lgfortran",
],
deps = [
"//path/to/some/dep",
"@some_external_dep//:dep",
],
alwayslink = True,
copts = ["-mavx", "-msse2", "-ftree-vectorize", "-fno-builtin-malloc", "-fno-builtin-calloc",
"-fno-builtin-realloc", "-fno-builtin-free", "-fopenmp", "-fopenmp-simd", "-funroll-loops",
"-Wfatal-errors", "-DENABLE_CUSTOM_LOGGER=1"],
visibility = ["//visibility:public"],
)
< /code>
load("//bazel:bundle.bzl", "bundle_cc_hdrs", "bundle_files")
cc_library(
name = "diskann_cc",
srcs = glob([
"*.cc",
]),
hdrs = glob([
"*.h",
]),
include_prefix = "diskann",
linkopts = [
],
deps = [
"//path/to/another/dep",
"//path/to/diskann_impl:diskann_impl",
],
alwayslink = True,
copts = ["-fPIC", "-DENABLE_CUSTOM_LOGGER=1"],
visibility = ["//visibility:public"],
)
cc_binary(
name = "libknn_diskann.so",
deps = [
":diskann_cc",
"//path/to/diskann_impl:diskann_impl",
],
linkshared = True,
visibility = ["//visibility:public"],
)
< /code>
Template class diskann::Indextemplate DISKANN_DLLEXPORT class Index;
< /code>
Building the diskann_cc target produces libdiskann.lo and libdiskann.so. Using the nm command, I can see that diskann::Index::build is an undefined symbol (U) in these files.
U diskann::Index::build(float const*, unsigned long, diskann::parameters const&, std::vector const&, bool)
< /code>
When I inspect the .lo file from diskann_impl, nm shows that this same symbol is a weak symbol (W).
00000000004e4424 W diskann::Index::build(float const*, unsigned long, diskann::parameters const&, std::vector const&, bool)
< /code>
How can I resolve the undefined symbol problem?
Подробнее здесь: https://stackoverflow.com/questions/797 ... nt-library