KleinYuan / Caffe2-iOS

Caffe2 on iOS Real-time Demo. Test with Your Own Model and Photos.
MIT License
227 stars 45 forks source link

Compile Error : linker command failed with exit code 1 #20

Closed blueicy closed 5 years ago

blueicy commented 7 years ago

Mac OS Sierra version 10.12.6 Xcode Version 8.3.3 IOS Version 10.3.3 MacBook Air 2011

Hi. Installing Caffe2-iOS seemed successful But when I compile caffe2-ios.xcodeproj, 72 warnings and 2 errors occurred. I have been trying to fix this error for few weeks. Does anyone know how to solve this problem?

Undefined symbols for architecture arm64: "caffe2::Predictor::~Predictor()", referenced from: -[Caffe2 reloadModel:predict:error:] in Caffe2.o -[Caffe2 loadDownloadedModel:predict:error:] in Caffe2.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Log of bash ./setup.sh

[Step1] Installing dependencies ./setup.sh: line 2: brew: command not found [Step2] git cloning Caffe2 Cloning into 'caffe2'...

..... [Step3] build ios Caffe2 codebase root is: /Users/mba1/caffe2/caffe2-ios/src/caffe2 Build Caffe2 ios into: /Users/mba1/caffe2/caffe2-ios/src/caffe2/build_ios Building protoc Other flags passed to cmake: -DCMAKE_C_FLAGS=-fembed-bitcode -DCMAKE_CXX_FLAGS=-fembed-bitcode -- The C compiler identification is AppleClang 8.1.0.8020042 -- The CXX compiler identification is AppleClang 8.1.0.8020042 -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works -- Detecting C compiler ABI info -- Checking if C linker supports --verbose -- Checking if C linker supports --verbose - no -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Checking if CXX linker supports --verbose -- Checking if CXX linker supports --verbose - no -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - found -- Found Threads: TRUE
-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.8") -- Configuring done -- Generating done -- Build files have been written to: /Users/mba1/caffe2/caffe2-ios/src/caffe2/build_host_protoc/build

.....

-- Performing Test CAFFE2_LONG_IS_INT32_OR_64 -- Performing Test CAFFE2_LONG_IS_INT32_OR_64 - Failed -- Need to define long as a separate typeid. -- Performing Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING -- Performing Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING - Failed -- Turning off deprecation warning due to glog. -- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS -- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS - Failed -- NCCL operators skipped due to no CUDA support -- Include NNPACK operators -- CUDA RTC operators skipped due to no CUDA support -- Including image processing operators -- Excluding video processing operators due to no opencv -- Excluding mkl operators as we are not using mkl -- MPI operators skipped due to no MPI support -- -- **** Summary **** -- General: -- Git version : -- System : Darwin -- C++ compiler : /usr/bin/g++ -- C++ compiler version : 8.1.0.8020042 -- Protobuf compiler : /Users/mba1/caffe2/caffe2-ios/src/caffe2/build_host_protoc/bin/protoc -- CXX flags : -fembed-bitcode -Wno-deprecated-declarations -Wno-deprecated -std=c++11 -O2 -fPIC -Wno-narrowing -- Build type : Release -- Compile definitions : CAFFE2_USE_EIGEN_FOR_BLAS;EIGEN_MPL2_ONLY;CAFFE2_UNIQUE_LONG_TYPEMETA -- -- BUILD_SHARED_LIBS : OFF -- BUILD_PYTHON : OFF -- Python version : -- Python library : -- BUILD_TEST : OFF -- USE_CUDA : OFF -- USE_NERVANA_GPU : OFF -- USE_GLOG : OFF -- USE_GFLAGS : OFF -- USE_LMDB : OFF -- USE_LEVELDB : OFF -- USE_OPENCV : ON -- OpenCV version : 2.4.11 -- USE_FFMPEG : -- USE_ZMQ : OFF -- USE_ROCKSDB : OFF -- USE_MPI : OFF -- USE_NCCL : OFF -- USE_NNPACK : ON -- USE_OPENMP : OFF -- USE_REDIS : OFF -- USE_GLOO : OFF -- Configuring done WARNING: Target "libprotoc" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it. CMake does not define behavior for this case. WARNING: Target "protoc" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it. CMake does not define behavior for this case. -- Generating done -- Build files have been written to: /Users/mba1/caffe2/caffe2-ios/src/caffe2/build_ios

......

ranlib libCaffe2_CPU.a [100%] Built target Caffe2_CPU /Users/mba1/anaconda/bin/cmake -E cmake_progress_start /Users/mba1/caffe2/caffe2-ios/src/caffe2/build_ios/CMakeFiles 0 [Tada!] Done


KleinYuan commented 7 years ago

@blueicy

I believe this is because of Caffe2 V0.8.0's changes. I updated the setup.sh and please run it again (or you can checkout v0.7.0 version on your own if you don't wanna clone it again).

I tested it on exact same env as yours and I can repeat your previous errors and my new commit will fix that.

Feel free to put an issue here anytime and let me know whether you can make it work.

blueicy commented 7 years ago

@KleinYuan Thanks for your reply! I should have put the issue bit earlier. I thought the errors were caused by somewhere between anaconda and home-brew, as I used to build Caffe2 with anaconda for MacOSX before installing Caffe2 iOS.

Just succeed compiling caffe2-ios app on iPhone by following the Step by Step Tutorial without Caffe2 for MacOSX.

Have not run the newly updated setup.sh with the same setting yet, I will try to install again with Caffe2 MacOSX then update how it works. Thanks again.

KleinYuan commented 7 years ago

@blueicy Sounds great.

Let me know whether you can compile it with the fix and then we can close this issue.