我试图将TensorFlow与我自己的共享库链接,并调用我在TF中开发的功能。
我有一个名为liba.so
的库,函数名称为funa()
,我将该库及其头文件放在了third_party/myownlib
中,在tensorflow/core/framework/
中修改了源代码
因此,我在How to add external header files during bazel/tensorflow build之后,通过
在third_party/myownlib
中创建了BUILD文件。
cc_library(
name = "liba",
hdrs = glob(["liba.h",]),
srcs = glob(["liba.so"]),
visibility = ["//visibility:public"],
)
并通过以下更改编辑了tensorflow/core/
中的BUILD文件:
name = "framework_internal_impl",
...
copts = tf_copts() + ["-Ithird_party/myownlib"],
linkopts = ["-la"] + select({
"//tensorflow:freebsd": ["-lm"],
"//tensorflow:windows": [],
"//conditions:default": [
"-ldl",
"-lm",
],
}),
deps = [
"//third_party/myownlib:liba",
] + if_static(
extra_deps = ["@protobuf_archive//:protobuf"],
otherwise = ["@protobuf_archive//:protobuf_headers"],
) + mkl_deps(),
alwayslink = 1,
)
但是我最终得到了/bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/tensorflow/contrib/framework/gen_gen_variable_ops_py_wrappers_cc , '\'''\'' 0 0 > bazel-out/k8-opt/genfiles/tensorflow/contrib/framework/python/ops/gen_variable_ops.py')
bazel-out/host/bin/tensorflow/contrib/framework/gen_gen_variable_ops_py_wrappers_cc: error while loading shared libraries: liba.so: cannot open shared object file: No such file or directory
我正在使用bazel 0.16.1和TF 1.11.0。