tensorflow: make "build_all_ios.sh" occur error

I try to build tensorflow support at Android and iOS by makefile tutorial in current master branch 04c318b69c5b565436cfeeaab1cb7fd5419dde27

When running the build_all_ios.sh script, the below error message show

Undefined symbols for architecture x86_64:
  "nsync::nsync_mu_init(nsync::nsync_mu_s_*)", referenced from:
      tensorflow::mutex::mutex() in env.o
      tensorflow::mutex::mutex() in random.o
  "nsync::nsync_mu_lock(nsync::nsync_mu_s_*)", referenced from:
      tensorflow::mutex::lock() in env.o
      tensorflow::mutex::lock() in random.o
      tensorflow::mutex::lock() in histogram.o
  "nsync::nsync_mu_unlock(nsync::nsync_mu_s_*)", referenced from:
      tensorflow::mutex::unlock() in env.o
      tensorflow::mutex::unlock() in random.o
      tensorflow::mutex::unlock() in histogram.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/CSL.Peter/tensorflow/tensorflow/tensorflow/contrib/makefile/gen/host_bin/proto_text] Error 1
+ '[' 2 -ne 0 ']'
+ echo 'armv7 compilation failed.'
armv7 compilation failed.
+ exit 1

The download_dependencies.sh and compile_ios_protobuf.sh run successfully but compile_ios_tensorflow.sh failed. I find same issues #3191 and #4252 and seem to be fixed at #4287, but this problem still happen.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

I was able to get around this by linking tensorflow/contrib/makefile/downloads/nsync/builds/lipo.ios.c++11/nsync.a in the other_linker flags

This seems to be some sort of Makefile / Bash issue on OSX where the $(HOST_NSYNC_LIB) env var in the Makefile is getting clobbered.

I was able to build for a while without this issue and then started to hit the same issue. I ran each command in build_all_ios.sh by hand and then it seemed to work.

Here is a simple patch to the Makefile which should fix the Undefined symbols error if you run into it.

diff --git a/tensorflow/contrib/makefile/Makefile b/tensorflow/contrib/makefile/Makefile index 525cf2cd4…e4893dde2 100644 — a/tensorflow/contrib/makefile/Makefile +++ b/tensorflow/contrib/makefile/Makefile @@ -86,7 +86,7 @@ endif HOST_INCLUDES += -I/usr/local/include

HOST_LIBS :=
-$(HOST_NSYNC_LIB)
+$(MAKEFILE_DIR)/downloads/nsync/builds/default.macos.c++11/nsync.a
-lstdc++
-lprotobuf
-lpthread
@@ -169,7 +169,7 @@ endif INCLUDES += -I/usr/local/include

LIBS :=
-$(TARGET_NSYNC_LIB)
+$(MAKEFILE_DIR)/downloads/nsync/builds/lipo.ios.c++11/nsync.a
-lstdc++
-lprotobuf
-lz \