sumulat ng libro dlib at opencv sa android ndk

bendaf 07/28/2017. 1 answers, 101 views
android android build android-ndk android-ndk dlib android-studio-2.3

Ako ay isang developer sa Android, ngunit bago ako sa Android NDK, mangyaring tumulong, o sabihin sa akin kung ano pa ang kailangan mo / paano mo susubukan na malutas ang ganitong uri ng problema.

Ginamit ko ang dlib na ito para sa android na halimbawa at opisyal na opencv para sa Android library at nais kong isama ang dalawa sa isang application. Kapag sinusubukan kong itayo ang proyekto nakukuha ko ang sumusunod na error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':openCVSamplefacedetection:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /home/feli/Android/Sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/Android.mk NDK_APPLICATION_MK=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/Application.mk APP_ABI=mips64 NDK_ALL_ABIS=mips64 NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/lib /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/libdetection_based_tracker.so}
  [mips64] Compile++      : detection_based_tracker <= DetectionBasedTracker_jni.cpp
  [mips64] Prebuilt       : libopencv_java3.so <= /home/feli/Android/openCV/OpenCV-android-sdk/sdk/native/jni/../libs/mips64/
  [mips64] SharedLibrary  : libdetection_based_tracker.so
  /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/objs-debug/detection_based_tracker/DetectionBasedTracker_jni.o: In function `dlib_check_consistent_assert_usage':
  /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/threads/threads_kernel_shared.h:44: undefined reference to `USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives_'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/libdetection_based_tracker.so] Error 1


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

Ang aking unang hulaan ay na ako haven / t kasama ang source.cpp sa aking Android.mk ngunit ilagay ito sa src file ay hindi malutas ang porblem. Narito ang aking Android.mk:

LOCAL_PATH := $(call my-dir)

## Build dlib to static library
include $(CLEAR_VARS)
LOCAL_MODULE := dlib
LOCAL_C_INCLUDES := $(LOCAL_PATH)/dlib

LOCAL_SRC_FILES += \
                $(LOCAL_PATH)/dlib/dlib/all/source.cpp \
                $(LOCAL_PATH)/dlib//dlib/threads/threads_kernel_shared.cpp \
                $(LOCAL_PATH)/dlib/dlib/entropy_decoder/entropy_decoder_kernel_2.cpp \
                $(LOCAL_PATH)/dlib/dlib/base64/base64_kernel_1.cpp \
                $(LOCAL_PATH)/dlib/dlib/threads/threads_kernel_1.cpp \
                $(LOCAL_PATH)/dlib/dlib/threads/threads_kernel_2.cpp

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
include $(BUILD_STATIC_LIBRARY)

# Build opencv
include $(CLEAR_VARS)
OPENCVROOT := ~/Android/openCV/OpenCV-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE := SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk

LOCAL_MODULE     := detection_based_tracker
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_SRC_FILES  := DetectionBasedTracker_jni.cpp

LOCAL_LDLIBS     += -lm -llog -ldl -lz -ljnigraphics
LOCAL_CPPFLAGS += -fexceptions -frtti -std=c++11

# LOCAL_STATIC_LIBRARIES += dlib

include $(BUILD_SHARED_LIBRARY) 

Siguro ang NDK_PROJECT_PATH=null ang problema? Kaysa sa kung bakit ang dalawang mga aklatan ay nagtatayo nang hiwalay? O ano pa ang maaaring problema? Sinubukan ko ang maraming pagbabago sa Android.mk, ngunit nagtatrabaho ito ay isang misteryo para sa akin. Ang anumang tulong o opinyon ay magiging kapaki-pakinabang.

EDIT:

Kapag LOCAL_STATIC_LIBRARIES += dlib ko ang LOCAL_STATIC_LIBRARIES += dlib row, nakuha ko ang sumusunod na pagbubukod:

Build command failed.
  Error while executing process /home/feli/Android/Sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/Android.mk NDK_APPLICATION_MK=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/Application.mk APP_ABI=mips64 NDK_ALL_ABIS=mips64 NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/lib /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/libdetection_based_tracker.so}
  [mips64] Compile++      : detection_based_tracker <= DetectionBasedTracker_jni.cpp
  [mips64] Compile++      : dlib <= source.cpp
  In file included from /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/all/source.cpp:76:
  In file included from /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/all/../gui_widgets/fonts.cpp:14:
  /home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/all/../gui_widgets/nativefont.h:27:10: fatal error: 'X11/Xlib.h' file not found
  #include            ^~~~~~~~~~~~
  1 error generated.
  make: *** [/home/feli/Development/android/test/face-detection/openCVSamplefacedetection/build/intermediates/ndkBuild/debug/obj/local/mips64/objs-debug/dlib//home/feli/Development/android/test/face-detection/openCVSamplefacedetection/src/main/jni/dlib/dlib/all/source.o] Error 1 
5 Comments
Alex Cohn 07/28/2017
Kailangan mo ba talagang bumuo ng MIPS? Kung balak mong patakbuhin ang iyong app sa mga aparatong ARM, idagdag ang abiFilters= "armeabi_v7a" sa iyong build.gradle script.
bendaf 07/30/2017
Ako ay tumatakbo sa abi arm64-v8a, ngunit binabago ko rin ang native c ++ code, kaya ipagpalagay ko na kailangan ko itong itayo din.
Alex Cohn 07/30/2017
Hindi ka dapat magkomento sa LOCAL_STATIC_LIBRARIES += dlib
bendaf 07/31/2017
Na-edit ko ang aking tanong, mangyaring suriin ito kung mayroon ka ng oras
1 Alex Cohn 07/31/2017
Hindi, hindi ka dapat mag-alala tungkol sa NDK_PROJECT_PATH , ganiyan kung paano configure ng Android Studio ang katutubong build sa pamamagitan ng ndk-build . Ngunit ang dlib ay nakabalangkas sa paligid ng cmake , kaya dapat muling buuin ang mga setting ng build na ginagamit doon.

1 Answers


Alex Cohn 07/31/2017.

Gumagamit ang dlib ng cmake , at ito ay hindi isang maliit na pag-setup. Maaaring tumagal ng isang mahabang panahon para sa isang propesyonal na karanasan upang ihanda ang ndk-build script para sa library na ito.

Iminumungkahi ko na itayo mo ang iyong katutubong library na may cmake , sa halip na ndk-build . Makakahanap ka ng isang halimbawa ng isang katutubong library na gumagamit ng OpenCv sa GitHub .

Gayundin, iminumungkahi ko na magsimula ka sa abiFilters set sa isang pinaka-may-katuturang ABI, at tanging kapag nakita mo na gumagana ang lahat para sa iyo, maaari mong buuin ang iyong proyekto para sa iba pang mga ABI. Tandaan na para sa ilang mga aklatan na nagpapalit sa lahat ng ABI ay maaaring nakakalito. At kung wala kang isang plataporma upang maisagawa ang hindi bababa sa isang maikling tseke sa kalinisan para sa ilang ABI, walang kahulugan sa pagtatayo para dito.

1 comments
bendaf 07/31/2017
Salamat, susubukan ko iyan!

Related questions

Hot questions

Language

Popular Tags