Closed wuyajun0627 closed 6 years ago
The Demo crashed when the function"maceMobilenetSetAttrs" is called.
@wuyajun19900627 Are ncnn and mace in seperated shared library? If so, this may be caused by openmp initialization conflict.
llvm-oenmp
restricts one copy of openmp
library built in target.
Two ways to avoid this:
@liyinhgqw Thanks a lot. I will take a shot
@llhe new logs:*Error:error: linker command failed with exit code 1 (use -v to see **invocation) FAILURE: Build failed with an exception.
Build command failed. Error while executing process /home/user/Android/Sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /home/user/AndroidStudioProjects/SceneRecognitionDemo/macelibrary/.externalNativeBuild/cmake/debug/arm64-v8a --target mace_mobile_jni} [1/3] Building CXX object CMakeFiles/mace_mobile_jni.dir/src/main/cpp/image_classify.cc.o [2/3] Building CXX object CMakeFiles/mace_mobile_jni.dir/src/main/cpp/mtcnn.cpp.o [3/3] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libmace_mobile_jni.so FAILED: : && /home/user/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android --gcc-toolchain=/home/user/Android/Sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 --sysroot=/home/user/Android/Sdk/ndk-bundle/sysroot -fPIC -isystem /home/user/Android/Sdk/ndk-bundle/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fopenmp -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math -std=c++11 -frtti -fexceptions -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a --sysroot /home/user/Android/Sdk/ndk-bundle/platforms/android-21/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libmace_mobile_jni.so -o ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libmace_mobile_jni.so CMakeFiles/mace_mobile_jni.dir/src/main/cpp/image_classify.cc.o CMakeFiles/mace_mobile_jni.dir/src/main/cpp/mtcnn.cpp.o ../../../../src/main/cpp/lib/arm64-v8a/libmace.a ../../../../src/main/cpp/model/arm64-v8a/mobilenet.a -llibncnn -ljnigraphics -lz /home/user/Android/Sdk/ndk-bundle/platforms/android-21/arch-arm64/usr/lib/liblog.so -lm "/home/user/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libgnustl_static.a" && : /home/user/Android/Sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -llibncnn clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.*
Here is my build.gradle: apply plugin: 'com.android.library' android { compileSdkVersion 26 defaultConfig { minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName "1.0" externalNativeBuild { cmake { arguments "-DANDROID_TOOLCHAIN=clang" cFlags "-fopenmp -O2 -fvisibility=hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math " cppFlags "-fopenmp -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math " cppFlags "" cppFlags "-std=c++11" cppFlags "-frtti" cppFlags "-fexceptions" } } } externalNativeBuild { cmake { path "CMakeLists.txt" } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }
sourceSets {
main {
// jniLibs.srcDirs = ["src/main/jniLibs"] jni.srcDirs = ['src/cpp'] } } // task ndkClean(type: Delete) { // delete fileTree('.externalNativeBuild') { // exclude defaultConfig.ndk.abiFilters.collect { '*/' + it } // } // } // tasks.findByPath(':clean').dependsOn ndkClean } dependencies { implementation fileTree(include: ['.jar'], dir: 'libs') }
**cannot find -llibncnn**
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.*
How can I solve this problem? @liyinhgqw
I'm not familiar with gradle, maybe use -L to specify where gradle can find ncnn?
Why do you link ncnn with mace anyway?
@liyinhgqw It's job demand. We try to use "ncnn" to help to improve the face detection rate,since our training model is not that good.
@llhe Is there a solution available?
Why do you use ncnn and mace together? Is it possible that you can use mace entirely?
I tested "ncnn", it is excellent in face detection. My training model file has some problems on face detection(It doesn't work well sometimes). So I want to take advantage of "ncnn" to do the job of detecting faces.
@wuyajun19900627 As an out-of-bound discussion, this is a Gradle build issue, which is not related to MACE or ncnn. So we can close it.
If there is still an issue after you build them into one shared library, fell free to reopen this.
Before you open an issue, please make sure you have tried the following steps:
System information
Model deploy file (*.yml)
Describe the problem
The Android Demo crashed when I try to put "ncnn" into it
To Reproduce
Steps to reproduce the problem:
Error information / logs
Please include the full log and/or traceback here.
Additional context
Add any other context about the problem here, e.g., what you have modified about the code.