Reputation: 704
I tried the example of TensorFlow C++ API (https://www.tensorflow.org/api_guides/cc/guide) on macOS.
What I did is:
Compiling was succeeded but the following error occurred.
dyld: Symbol not found: __ZN10tensorflow10DEVICE_CPUE
Referenced from: /private/var/tmp/_bazel_yuji/a8fcd93e6cfa4967cc9ea4c6e4cf2977/execroot/org_tensorflow/bazel-out/darwin_x86_64-py3-opt/bin/tensorflow/cc/example/example
Expected in: flat namespace
in /private/var/tmp/_bazel_yuji/a8fcd93e6cfa4967cc9ea4c6e4cf2977/execroot/org_tensorflow/bazel-out/darwin_x86_64-py3-opt/bin/tensorflow/cc/example/example
The example does not use the global variable DEVICE_CPU, so it seems tensorflow library issue.
How can I avoid it?
I tried the same things on Ubuntu and got many linker errors in the last stage of compiling such as,
error: undefined reference to <symbol name>
Upvotes: 1
Views: 599
Reputation: 704
I finally found the solution.
BUILD below in the guide might not be suitable for the latest tensorflow.
cc_binary(
name = "example",
srcs = ["example.cc"],
deps = [
"//tensorflow/cc:cc_ops",
"//tensorflow/cc:client_session",
"//tensorflow/core:tensorflow",
],
)
I modified it according to BUILD in tensorflow/cc.
load(
"//tensorflow:tensorflow.bzl",
"tf_cc_binary",
)
tf_cc_binary(
name = "example",
srcs = ["example.cc"],
deps = [
"//tensorflow/cc:cc_ops",
"//tensorflow/cc:client_session",
"//tensorflow/core:tensorflow",
],
)
That's all.
Upvotes: 2