GithubHelp home page GithubHelp logo

Comments (5)

sh1r0 avatar sh1r0 commented on June 6, 2024

Thanks for sharing your experience. I just noticed that gcc-4.6 toolchain was removed in ndk-r10e, and thus I made some fixes on this. Now, it should be okay to use build.py direclty. Please feel free to let me know if there are any problems.

from caffe-android-lib.

ZhengRui avatar ZhengRui commented on June 6, 2024

There are two things which i don't understand now

1, it seems in you build.py file, you are using LOCAL_LDLIBS += -l... to link Boost-for-Android, Do you compile Boost-for-Android to be shared libraries? because i can only compile it to be static libraries and then use the way i mentioned above to link to these static libraries, so i am wondering how you do that?

2, in my MainActivity, i can create an CaffeMobile instance, but when i call enableLog() method, it generates errors, here is my LogCat:

06-12 21:04:37.920 2183-2183/com.rzheng.deepandroid D/dalvikvm﹕ Trying to load lib /data/app-lib/com.rzheng.deepandroid-2/libcaffe.so 0x4357e240
06-12 21:04:37.950 2183-2183/com.rzheng.deepandroid D/dalvikvm﹕ Added shared lib /data/app-lib/com.rzheng.deepandroid-2/libcaffe.so 0x4357e240
06-12 21:04:37.950 2183-2183/com.rzheng.deepandroid D/dalvikvm﹕ No JNI_OnLoad found in /data/app-lib/com.rzheng.deepandroid-2/libcaffe.so 0x4357e240, skipping init
06-12 21:04:37.950 2183-2183/com.rzheng.deepandroid D/dalvikvm﹕ Trying to load lib /data/app-lib/com.rzheng.deepandroid-2/libcaffe_jni.so 0x4357e240
06-12 21:04:37.950 2183-2183/com.rzheng.deepandroid D/dalvikvm﹕ Added shared lib /data/app-lib/com.rzheng.deepandroid-2/libcaffe_jni.so 0x4357e240
06-12 21:04:37.990 2183-2183/com.rzheng.deepandroid I/MainActivity:﹕ Loading caffe successfully
06-12 21:05:40.710 2868-2868/? D/dalvikvm﹕ Trying to load lib /data/app-lib/com.rzheng.deepandroid-1/libcaffe.so 0x43573d20
06-12 21:05:40.740 2868-2868/? D/dalvikvm﹕ Added shared lib /data/app-lib/com.rzheng.deepandroid-1/libcaffe.so 0x43573d20
06-12 21:05:40.740 2868-2868/? D/dalvikvm﹕ No JNI_OnLoad found in /data/app-lib/com.rzheng.deepandroid-1/libcaffe.so 0x43573d20, skipping init
06-12 21:05:40.740 2868-2868/? D/dalvikvm﹕ Trying to load lib /data/app-lib/com.rzheng.deepandroid-1/libcaffe_jni.so 0x43573d20
06-12 21:05:40.740 2868-2868/? D/dalvikvm﹕ Added shared lib /data/app-lib/com.rzheng.deepandroid-1/libcaffe_jni.so 0x43573d20
06-12 21:05:40.780 2868-2868/? I/MainActivity:﹕ Loading caffe successfully
06-12 21:05:40.780 2868-2868/? W/dalvikvm﹕ No implementation found for native Lcom/rzheng/deepandroid/CaffeMobile;.enableLog:(Z)V
06-12 21:05:40.780 2868-2868/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.rzheng.deepandroid, PID: 2868
java.lang.UnsatisfiedLinkError: Native method not found: com.rzheng.deepandroid.CaffeMobile.enableLog:(Z)V
at com.rzheng.deepandroid.CaffeMobile.enableLog(Native Method)
at com.rzheng.deepandroid.MainActivity.onCreate(MainActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5249)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2154)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2239)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5047)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)

I used the libcaffe.so and libcaffe_jni.so i built by myself, and my package name is com.rzheng.deepandroid, in issue #6, I saw that you mentioned that i have to build the library by myself instead of directly use the .so files in your caffe-android-demo project, but i use the .so files built by myself. I noticed that there is a '-L' option in build.py, does it have something to do with that? what could be the reasons?

from caffe-android-lib.

ZhengRui avatar ZhengRui commented on June 6, 2024

My second question solved, have to change the 3 methods name in caffe_jni.cpp file to the names corresponds to my Android Project name and compile caffe-mobile again, now it works. But i am wondering can you make caffe_jni.cpp file more general, otherwise i have to change it and built it again each time i create a new Android project?

from caffe-android-lib.

sh1r0 avatar sh1r0 commented on June 6, 2024

In the previous commit (6604a37), static boost libs can be linked simply by using LOCAL_LDLIBS (with warnings). However, boost is not required In the latest commit (c021b34)。
This repo is aim at providing a ported Caffe as a (general) lib on Android, where caffe_jni.cpp is no more than an example.
Trying to wrap all you need within jni and provide general interfaces for java is recommended. The jni part should be as general as possible and independent to your android projects.

from caffe-android-lib.

bhack avatar bhack commented on June 6, 2024

@ZhengRui For more general jni coverage see bytedeco/javacpp-presets#34.

from caffe-android-lib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.