sh1r0 / caffe-android-lib

Porting caffe to android platform
Other
510 stars 204 forks source link

NDK Fail Build with libcaffe.a #96

Closed filipetrocadoferreira closed 7 years ago

filipetrocadoferreira commented 7 years ago

/home/filipeferreira/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lstlport /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/caffe/lib/libcaffe.a(io.cpp.o):io.cpp:function caffe::ReadImageToCVMat(std::string const&, int, int, bool): error: undefined reference to 'cv::String::allocate(unsigned int)' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/caffe/lib/libcaffe.a(io.cpp.o):io.cpp:function caffe::ReadImageToCVMat(std::string const&, int, int, bool): error: undefined reference to 'cv::imread(cv::String const&, int)' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/caffe/lib/libcaffe.a(io.cpp.o):io.cpp:function caffe::ReadImageToCVMat(std::string const&, int, int, bool): error: undefined reference to 'cv::String::deallocate()' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/caffe/lib/libcaffe.a(io.cpp.o):io.cpp:function caffe::ReadImageToCVMat(std::string const&, int, int, bool): error: undefined reference to 'cv::String::deallocate()' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/caffe/lib/libcaffe.a(io.cpp.o):io.cpp:function caffe::ReadImageToDatum(std::string const&, int, int, int, bool, std::string const&, caffe::Datum*): error: undefined reference to 'cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/caffe/lib/libcaffe.a(io.cpp.o):io.cpp:function caffe::ReadImageToDatum(std::string const&, int, int, int, bool, std::string const&, caffe::Datum*): error: undefined reference to 'cv::String::deallocate()' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/caffe/lib/libcaffe.a(io.cpp.o):io.cpp:function caffe::ReadImageToDatum(std::string const&, int, int, int, bool, std::string const&, caffe::Datum*): error: undefined reference to 'cv::String::allocate(unsigned int)' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/caffe/lib/libcaffe.a(io.cpp.o):io.cpp:function caffe::ReadImageToDatum(std::string const&, int, int, int, bool, std::string const&, caffe::Datum*): error: undefined reference to 'cv::String::deallocate()' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/glog/lib/libglog.a(logging.cc.o):logging.cc:function google::(anonymous namespace)::LogFileObject::Write(bool, long, char const*, int): error: undefined reference to 'posix_fadvise' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/glog/lib/libglog.a(logging.cc.o):logging.cc:function _GLOBAL__sub_I_logging.cc: error: undefined reference to 'getpagesize' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/glog/lib/libglog.a(signalhandler.cc.o):signalhandler.cc:function google::(anonymous namespace)::InvokeDefaultSignalHandler(int): error: undefined reference to 'sigemptyset' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/glog/lib/libglog.a(signalhandler.cc.o):signalhandler.cc:function google::glog_internal_namespace_::IsFailureSignalHandlerInstalled(): error: undefined reference to 'sigemptyset' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/glog/lib/libglog.a(signalhandler.cc.o):signalhandler.cc:function google::InstallFailureSignalHandler(): error: undefined reference to 'sigemptyset' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/protobuf/lib/libprotobuf.a(strutil.cc.o):strutil.cc:function google::protobuf::safe_strtof(char const*, float*): error: undefined reference to 'strtof' /home/filipeferreira/workspace/HealthyDrive/src/jni/android_lib/protobuf/lib/libprotobuf.a(strutil.cc.o):strutil.cc:function google::protobuf::FloatToBuffer(float, char*): error: undefined reference to '__isnanf'

i get these errors when trying to compile with ndk-build and using a static libcaffe

sh1r0 commented 7 years ago

@filipetrocadoferreira How did you build?

DevilGragon commented 7 years ago

Hi, I am also doing my work which needs to build libcaffe.a, do you solve this problem and make it? @filipetrocadoferreira Sorry to bother you again, @sh1r0 . I want to implement caffe test in android demo-borad, but it seems that dynamic linking can't be supported in android platform, So I try to make a static link, but after several attemps I failed. What do I need to modify? Is it caffe-root's makefile or some other files? Thank you for your advice.

sh1r0 commented 7 years ago

@DevilGragon Please refer to https://github.com/sh1r0/caffe-android-lib/issues/75, thanks.

filipetrocadoferreira commented 7 years ago

I was trying to compile my .so with libcaffe.a in armeabi-v7a, with ndk 4.9 . Idk why but I was not able. The solution for me was to compile libcaffe.so in arm64-v8a (even libcaffe.so in armeabi-v7a I couldn't) and refer to my project.

sh1r0 commented 7 years ago

@filipetrocadoferreira Which version of NDK do you use?

raginisharma14 commented 7 years ago

@filipetrocadoferreira: can you try using NDK version r10, you can actually see the versions of NDK that are supported. They are mentioned here https://github.com/sh1r0/android-cmake/blob/ff958185a121cc315c309b72a3b88a0ffa2d3880/android.toolchain.cmake#L220

sh1r0 commented 7 years ago

Could be reopened if needed.