Skip to content

Link error using c api: undefined reference to symbol 'powf@@GLIBC_2.2.5' #332

@chenghuige

Description

@chenghuige

http://theyoungcoder.com/loading-a-tensorflow-graph-with-the-c-api/
I followed this acticle.

1 cc_binary(
2 name = "loader",
3 srcs = ["loader.cc"],
4 deps = [
5 "//tensorflow/core:tensorflow",
6 ]
7 )
Here’s the final directory structure:
• tensorflow/tensorflow/loader/
• tensorflow/tensorflow/loader/loader.cc
• tensorflow/tensorflow/loader/BUILD
Compile & Run
• From inside the project folder call bazel build :loader.
• From the repository root, go into bazel-bin/tensorflow/loader.
• Copy the graph protobuf to models/train.pb.

Then run ./loader and check the output!

But when building I got link error
Slow read: a 551318010-byte read from /home/users/chenghuige/.cache/bazel/_bazel_chenghuige/56e262ed5e70da1d7ac42e55562c6970/tensorflow/bazel-out/local_linux-fastbuild/bin/tensorflow/core/libkernels.lo took 6143ms.
INFO: From Linking tensorflow/loader/loader:
/usr/bin/ld: bazel-out/local_linux-fastbuild/bin/tensorflow/core/libkernels.lo(cwise_op_pow.pic.o): undefined reference to symbol 'powf@@GLIBC_2.2.5'
/usr/bin/ld: note: 'powf@@GLIBC_2.2.5' is defined in DSO /top/lib/libm.so.6 so try adding it to the linker command line
/top/lib/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
ERROR: /home/users/chenghuige/other/tensorflow/tensorflow/loader/BUILD:1:1: Linking of rule '//tensorflow/loader:loader' failed: gcc failed: error executing command /usr/bin/gcc -o bazel-out/local_linux-fastbuild/bin/tensorflow/loader/loader bazel-out/local_linux-fastbuild/bin/tensorflow/loader/_objs/loader/tensorflow/loader/loader.pic.o -Wl,-whole-archive ... (remaining 45 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //tensorflow/loader:loader failed to build
Use --verbose_failures to see the command lines of failed build steps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions