2017-07-28 3 views
1

私はアンドロイドの開発者ですが、私はAndroid NDKを初めてお使いになりましたか、助けてください、他に何が必要でしょうか/このタイプの問題を解決する方法を教えてください。dlibとopencvをandroid ndkでコンパイルします

アンドロイドの例ではthis dlib、公式の場合はopencv for android libraryを使用しました。この2つを1つのアプリケーションに統合したいと考えています。私はプロジェクトをビルドしようとすると、私は次のエラーを取得する:

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. 

は私の最初の推測では、Iの避難所/ tは私のAndroid.mkでsource.cppを含むが、SRCファイルにそれをplaceingが解決しなかったということでしたポーランド。ここ は私の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) 

たぶんNDK_PROJECT_PATH=nullが問題でしょうか?なぜ2つの図書館が別々に建てられているのですか?それ以外に何が問題なの?私はAndroid.mkを大きく修正しようとしましたが、動作しているのは私の謎です。 助けや意見が役に立ちます。

編集:私はLOCAL_STATIC_LIBRARIES += dlib行をコメントアウトすると

、私は次の例外を得た:

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 <X11/Xlib.h> 
      ^~~~~~~~~~~~ 
    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 
+0

本当にMIPSビルドが必要ですか? ARMデバイスでアプリケーションを実行する場合は、** build.gradle **スクリプトに** abiFilters = "armeabi_v7a" **を追加します。 –

+0

私はabi arm64-v8aを実行していますが、ネイティブなC++コードも変更していますので、ビルドする必要があると思います。 – bendaf

+0

あなたは 'LOCAL_STATIC_LIBRARIES + = dlib'をコメントアウトしないでください。 –

答えて

2

dlibcmakeのを使用し、それは些細な設定ではありません。経験豊富なプロフェッショナルがこのライブラリ用のndk-buildスクリプトを準備するのに時間がかかる場合があります。

私はあなたの代わりにNDK-構築の、cmakeのであなたのネイティブライブラリを構築することを示唆しています。 OpenCv on GitHubを使用するネイティブライブラリの例があります。

abiFiltersは、関連性の高いABIが1つだけ設定されていることをお勧めします。他のABIのプロジェクトを構築することができます。一部のライブラリでは、すべてのABIに移植するのが難しいかもしれないことに注意してください。そして、あなたがABIのために少なくとも簡単な健全性チェックを実行するプラットフォームを持っていないなら、それを構築する意味はありません。

+0

ありがとう、私はそれを試みる! – bendaf

関連する問題