solrex / caffe-mobile

Optimized (for size and speed) Caffe lib for iOS and Android with out-of-the-box demo APP.
Other
317 stars 121 forks source link

incompatible target, collect2: error: ld return 1 exit status #5

Closed suguliwei closed 7 years ago

suguliwei commented 7 years ago

Hi @solrex ,A problem has been bother me for a while. The target I use is Android. When I came to the last step to create libcaffe-jni.so, it told me that some of the openblas static link file are incompatible targets.What do you think I should do to fix this issue?Apart from cross compile chain reason, is there other reasons result in this problem?If it's cross compile chain problem, how could I make sure that the next configuration is correct?

solrex commented 7 years ago

Hi @suguliwei, I have tested the build script on Ubuntu 16.04 with android-ndk-r13b. It works well.

What is your build environment like? Did you build the target in a clean environment? Did you have other version of blas library(openblas/atlas) installed? Could you please attach the full build log here for more information?

suguliwei commented 7 years ago

Hi @solrex ,thanks for your reply. After redeploy my build environment and execute "cmake .. -DCMAKE_TOOLCHAIN_FILE=../third_party/android-cmake/android.toolchain.cmake \ -DANDROID_NDK=$NDK_HOME \ -DANDROID_ABI="arm64-v8a" \ -DANDROID_NATIVE_API_LEVEL=21 \ -DTHIRD_PARTY=1", here comes a new problem. CMake Error at /usr/local/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message): Could NOT find Protobuf (missing: Protobuf_LIBRARIES) (found version "3.1.0") Call Stack (most recent call first): /usr/local/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) /usr/local/share/cmake-3.7/Modules/FindProtobuf.cmake:393 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) cmake/ProtoBuf.cmake:4 (find_package) CMakeLists.txt:36 (include)

And the following is content of CMakeError.log. Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc Build flags: Id flags:

The output was: 1 /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find crtbegin_dynamic.o: No such file or directory /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lc /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -ldl /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find crtend_android.o: No such file or directory collect2: error: ld returned 1 exit status

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-g++ Build flags: Id flags:

The output was: 1 /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find crtbegin_dynamic.o: No such file or directory /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lstdc++ /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lm /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lc /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -ldl /home/ss/android/android-ndk-r13b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find crtend_android.o: No such file or directory collect2: error: ld returned 1 exit status

Here is my build environment. Ubuntu 16.04,android-ndk-r13b,cmake-3.7.2.

solrex commented 7 years ago

Hi @suguliwei , did you follow the README.md step by step? It seems you failed to build protobuf lib in third_party dir.

I noticed your cmake was not installed by apt install. I guess you have already installed a lot of stuffs, set many environment variables. Perhaps your problem is caused by the complicate building environment. Could you please try rebuilding in a clean docker or virtual machine? That might help you to cross-validate what the problem is.

suguliwei commented 7 years ago

Hi @solrex ,problem has been solved.I am very grateful for your answers.