TensorFlowAndroidDemo icon indicating copy to clipboard operation
TensorFlowAndroidDemo copied to clipboard

Problem compiling jni_libs when try to add new function

Open andrimirandi opened this issue 8 years ago • 0 comments

I am trying to add new functionalities to the jni libraries but failed, I try to add the following on tensorflow_jni.h JNIEXPORT jstring JNICALL TENSORFLOW_METHOD(test)( JNIEnv* env, jobject thiz);

on tensorflow_jni.cc JNIEXPORT jstring JNICALL TENSORFLOW_METHOD(test)( JNIEnv* env, jobject thiz){ return env->NewStringUTF("test"); }

then I run make and the results is as follow

Android NDK: WARNING:jni/Android.mk:tensorflow_demo: non-system libraries in linker flags: jni/libs/armeabi-v7a/libprotos_all_cc.a jni/libs/armeabi-v7a/libprotobuf.a jni/libs/armeabi-v7a/libprotobuf_lite.a /opt/android-ndk-r13b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a /opt/android-ndk-r13b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libsupc++.a
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
make[1]: Entering directory `/home/srin/TensorFlowAndroidDemo/jni-build' [armeabi-v7a] Compile++ arm : tensorflow_demo <= imageutils_jni.cc [armeabi-v7a] Compile++ arm : tensorflow_demo <= jni_utils.cc [armeabi-v7a] Compile++ arm : tensorflow_demo <= rgb2yuv.cc [armeabi-v7a] Compile++ arm : tensorflow_demo <= tensorflow_jni.cc [armeabi-v7a] Compile++ arm : tensorflow_demo <= yuv2rgb.cc [armeabi-v7a] SharedLibrary : libtensorflow_demo.so [armeabi-v7a] Install : libtensorflow_demo.so => libs/armeabi-v7a/libtensorflow_demo.so

the compile is success, but when I try to run it it returns the error Function not found then I try to look at the generated library and got the following instead

nm -D libs/armeabi-v7a/libtensorflow_demo.so | grep Java_org_tensorflow 00073770 T Java_org_tensorflow_demo_env_ImageUtils_convertARGB8888ToYUV420SP 0007382c T Java_org_tensorflow_demo_env_ImageUtils_convertRGB565ToYUV420SP 00073458 T Java_org_tensorflow_demo_env_ImageUtils_convertYUV420SPToARGB8888 000736c4 T Java_org_tensorflow_demo_env_ImageUtils_convertYUV420SPToRGB565 00073548 T Java_org_tensorflow_demo_env_ImageUtils_convertYUV420ToARGB8888 00075cf8 T Java_org_tensorflow_demo_TensorFlowClassifier_classifyImageBmp 00075c4c T Java_org_tensorflow_demo_TensorFlowClassifier_classifyImageRgb 00075f38 T Java_org_tensorflow_demo_TensorFlowClassifier_initializeTensorFlow 00074b54 T _Z50Java_org_tensorflow_demo_TensorFlowClassifier_testP7_JNIEnvP8_jobject

it seems that the function name is deformed,... I try several times and eventually when I try to rename the function that has successfully compiled such as initializeTensorFlow to initializeTensorFlow1 the function name become deformed too

nm -D libs/armeabi-v7a/libtensorflow_demo.so | grep Java_org_tensorflow 00073740 T Java_org_tensorflow_demo_env_ImageUtils_convertARGB8888ToYUV420SP 000737fc T Java_org_tensorflow_demo_env_ImageUtils_convertRGB565ToYUV420SP 00073428 T Java_org_tensorflow_demo_env_ImageUtils_convertYUV420SPToARGB8888 00073694 T Java_org_tensorflow_demo_env_ImageUtils_convertYUV420SPToRGB565 00073518 T Java_org_tensorflow_demo_env_ImageUtils_convertYUV420ToARGB8888 00075cb0 T Java_org_tensorflow_demo_TensorFlowClassifier_classifyImageBmp 00075c04 T Java_org_tensorflow_demo_TensorFlowClassifier_classifyImageRgb 00075ef0 T Z67Java_org_tensorflow_demo_TensorFlowClassifier_initializeTensorFlow1P7_JNIEnvP8_jobjectS2_P8_jstringS4_iiifS4_S4

how can I add new functionalities ? are there any other files that I need to edit ? I compile with android-ndk-r13b

Thanks

andrimirandi avatar Mar 24 '17 11:03 andrimirandi