tensorflow: libtensorflow_cc.so linker issues with r 1.3 on Mac OS X Undefined symbols for architecture
System information
-
Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes, but this appears to be a linker issue.
-
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac OS X 10.12.6
-
TensorFlow installed from (source or binary): Source
-
TensorFlow version (use command below): Git tagged at 1.3 and master at 593dc8e5d65f4db93e8f5fced772abb3531a9752
-
Python version: 2.7 (OS Default).
-
Bazel version (if compiling from source): 0.5.3-homebrew
-
CUDA/cuDNN version: N/A
-
GPU model and memory: N/A
-
Exact command to reproduce: bazel clean ./configure stating N to every option for CPU only build. bazel build //tensorflow:libtensorflow_cc.so with no optimizations (testing deployment)
Describe the problem
The above commands builds a libtensorflow_cc.so from for TF 1.3
Linking my built libtensorflow_cc.so to a C++ / Obj-C App which has successfully linked against a TF 1.2 build of libtensorflow_cc.so, results in the following linker errors in the log section of this bug report.
No code changes were made on my end between a working 1.2 libtensorflow_cc.so and a new 1.3 libtensorflow_cc.so - Just replacing the binary so file, building clean and re-compiling.
Thank you.
Source code / logs
cd /Users/vade/Documents/Repositories/Synopsis/Synopsis/Synopsis/Synopsis-Framework/Synopsis
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -L/Users/vade/Library/Developer/Xcode/DerivedData/Synopsis-cdbnfomidhkpiodcmhdwciqcvshg/Build/Products/Release -L/Users/vade/Documents/Repositories/Synopsis/Synopsis/Synopsis/Synopsis-Framework/Synopsis/Synopsis/Tensorflow/lib -F/Users/vade/Library/Developer/Xcode/DerivedData/Synopsis-cdbnfomidhkpiodcmhdwciqcvshg/Build/Products/Release -F/Users/vade/Documents/Repositories/Synopsis/Synopsis/Synopsis/Synopsis-Framework/Synopsis/Synopsis/OpenCV -filelist /Users/vade/Library/Developer/Xcode/DerivedData/Synopsis-cdbnfomidhkpiodcmhdwciqcvshg/Build/Intermediates/Synopsis-Framework.build/Release/Synopsis-macOS.build/Objects-normal/x86_64/Synopsis.LinkFileList -install_name @rpath/Synopsis.framework/Versions/A/Synopsis -Xlinker -rpath -Xlinker @executable_path/../Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -mmacosx-version-min=10.11 -Xlinker -object_path_lto -Xlinker /Users/vade/Library/Developer/Xcode/DerivedData/Synopsis-cdbnfomidhkpiodcmhdwciqcvshg/Build/Intermediates/Synopsis-Framework.build/Release/Synopsis-macOS.build/Objects-normal/x86_64/Synopsis_lto.o -fobjc-arc -fobjc-link-runtime -stdlib=libc++ -lblas -framework Accelerate -lz -framework Cocoa -framework CoreMedia -framework CoreMediaIO -framework CoreVideo -framework OpenCL -framework opencv2 /Users/vade/Documents/Repositories/Synopsis/Synopsis/Synopsis/Synopsis-Framework/Synopsis/Synopsis/Tensorflow/lib/libtensorflow_cc.so -single_module -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/vade/Library/Developer/Xcode/DerivedData/Synopsis-cdbnfomidhkpiodcmhdwciqcvshg/Build/Intermediates/Synopsis-Framework.build/Release/Synopsis-macOS.build/Objects-normal/x86_64/Synopsis_dependency_info.dat -o /Users/vade/Library/Developer/Xcode/DerivedData/Synopsis-cdbnfomidhkpiodcmhdwciqcvshg/Build/Products/Release/Synopsis.framework/Versions/A/Synopsis
Undefined symbols for architecture x86_64:
"tensorflow::TensorShape::SlowCopyFrom(tensorflow::TensorShape const&)", referenced from:
tensorflow::Tensor::Tensor(tensorflow::Tensor const&) in TensorflowFeatureModule.o
"tensorflow::TensorShape::DestructorOutOfLine()", referenced from:
-[TensorflowFeatureModule initWithQualityHint:] in TensorflowFeatureModule.o
tensorflow::Tensor::Tensor(tensorflow::Tensor const&) in TensorflowFeatureModule.o
"tensorflow::TensorShape::TensorShape(tensorflow::gtl::ArraySlice<long long>)", referenced from:
-[TensorflowFeatureModule initWithQualityHint:] in TensorflowFeatureModule.o
"tensorflow::TensorShape::dim_size(int) const", referenced from:
Eigen::DSizes<long, 4> tensorflow::TensorShape::AsEigenDSizesWithPadding<4>() const in TensorflowFeatureModule.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24 (14 by maintainers)
Note that
libtensorflow_cc.so
has a dependency onlibtensorflow_framework.so
. Can you run:otool -L libtensorflow_cc.so
and provide the output?I suspect what’s happening is that the linker isn’t finding
libtensorflow_framework.so
in its path. When we build the C libraries for release we package both libraries and set therpath
appropriately.@tho15 : The
-ltensorflow_framework
argument should be after the source file. Can you try putting it at the end (aftertf_classifier.cc
)?@asimshankar after add mkl library and put the -ltensorflow_cc -ltensorflow_framework after the source file. It works now. Many thanks for you help!
#14632 issue can be closed.