Skip to content

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

Closed

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.

Activity

  1. changed the title [-]Link error using[/-] [+]Link error using c api : undefined reference to symbol 'powf@@GLIBC_2.2.5'[/+] on Nov 23, 2015
  2. changed the title [-]Link error using c api : undefined reference to symbol 'powf@@GLIBC_2.2.5'[/-] [+]Link error using c api: undefined reference to symbol 'powf@@GLIBC_2.2.5'[/+] on Nov 23, 2015
  3. mrry commented on Nov 30, 2015

    @mrry
    Contributor

    It sounds like you're using an older version of glibc than we support (2.2.5, rather than 2.17). You could try adding "-lm" to the returned value from tf_copts() in tensorflow.bzl (see here), but there might be other problems that arise afterwards.

    I'd recommend trying to update the version of libc on your machine, or using a Docker container to experiment with a different operating system in a known-good configuration.

  4. chenghuige commented on Dec 1, 2015

    @chenghuige
    Author

    @mrry
    ll -t libm.so.6
    lrwxrwxrwx 1 root root 12 Jul 3 17:57 libm.so.6 -> libm-2.18.so

    seems libm.so.6 is of version 2.18 ?

    Adding -lm will not solve this problem.
    Also I can use bazel build tensorflow project successfully but I can not build this example

  5. girving commented on Dec 7, 2015

    @girving
    Contributor

    @mrry: Should we close as won't fix due to the version issue?

  6. mrry commented on Dec 7, 2015

    @mrry
    Contributor

    I think so. It sounds like a Bazel issue, not picking up the appropriate libraries from a non-standard location.

  7. added a commit that references this issue on Jan 23, 2020
  8. added a commit that references this issue on May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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