在Android NDK中使用支持c ++ 11编译opencv库的问题

时间:2015-08-06 19:17:14

标签: android c++11 android-ndk opencv4android

所有

我有问题在Android NDK中使用支持c ++ 11编译opencv库,我有一个配置opencv 2.4.11的项目,我需要使用一些支持c ++ 11的类,但是当我启用c +时项目中的+11并使用Android NDK进行编译,该项目无法正常工作。

我做了下一个内部jni文件夹:

  1. 在下一个文件中启用c ++ 11:
  2. Android.mk文件

    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)
    OPENCV_CAMERA_MODULES:=off
    OPENCV_INSTALL_MODULES:=off
    OPENCV_LIB_TYPE:=STATIC
    include /OpenCV-android-sdk/sdk/native/jni/OpenCV.mk
    LOCAL_SRC_FILES  := DetectionBasedTracker_jni.cpp
    LOCAL_C_INCLUDES += $(LOCAL_PATH)
    LOCAL_LDLIBS     += -llog -ldl
    LOCAL_MODULE     := detection_based_tracker
    include $(BUILD_STATIC_LIBRARY)
    

    Application.mk文件

    //change gnustl_static to c++_static
    APP_STL := c++_static
    //add -std=c++11 to enable support c++11
    APP_CPPFLAGS += -std=c++11 -frtti -fexceptions
    APP_ABI :=  armeabi-v7a
    APP_PLATFORM := android-13
    NDK_TOOLCHAIN_VERSION := 4.8
    

    当我使用NDK命令编译ndk-build时,我有下一个错误:

    OpenCV-android-    sdk/sdk/native/jni/include/opencv2/core/operations.hpp:77:29: fatal error: atomicity.h: No such file or directory #include <atomicity.h>
    

    你能帮我解决问题吗,谢谢你。

    执行ndk-build V = 1

    后记录cat
    m -f ./libs/arm64-v8a/lib*.so ./libs/armeabi/lib*.so ./libs/armeabi-v7a/lib*.so ./libs/armeabi-v7a-hard/lib*.so ./libs/mips/lib*.so ./libs/mips64/lib*.so ./libs/x86/lib*.so ./libs/x86_64/lib*.so
    rm -f ./libs/arm64-v8a/gdbserver ./libs/armeabi/gdbserver ./libs/armeabi-v7a/gdbserver ./libs/armeabi-v7a-hard/gdbserver ./libs/mips/gdbserver ./libs/mips64/gdbserver ./libs/x86/gdbserver ./libs/x86_64/gdbserver
    rm -f ./libs/arm64-v8a/gdb.setup ./libs/armeabi/gdb.setup ./libs/armeabi-v7a/gdb.setup ./libs/armeabi-v7a-hard/gdb.setup ./libs/mips/gdb.setup ./libs/mips64/gdb.setup ./libs/x86/gdb.setup ./libs/x86_64/gdb.setup
    [armeabi] Compile++ thumb: detection_based_tracker <= DetectionBasedTracker_jni.cpp
    /Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/toolchains/llvm-3.6/prebuilt/darwin-x86_64/bin/clang++ -MMD -MP -MF ./obj/local/armeabi/objs/detection_based_tracker/DetectionBasedTracker_jni.o.d -gcc-toolchain /Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64 -fpic -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -fno-integrated-as  -target armv5te-none-linux-androideabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -I"../../../OpenCV-android-sdk/sdk/native/jni/include/opencv" -I"../../../OpenCV-android-sdk/sdk/native/jni/include" -Ijni -I/Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libcxx/include -I/Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/../llvm-libc++abi/libcxxabi/include -I/Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/../../android/support/include -Ijni -DANDROID -fPIC -DANDROID -fsigned-char -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++11   -std=c++11 -frtti -fexceptions  -I/Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/platforms/android-8/arch-arm/usr/include -c  jni/DetectionBasedTracker_jni.cpp -o ./obj/local/armeabi/objs/detection_based_tracker/DetectionBasedTracker_jni.o 
    In file included from jni/DetectionBasedTracker_jni.cpp:2:
    In file included from ../../../OpenCV-android-sdk/sdk/native/jni/include/opencv2/core/core.hpp:59:
    In file included from /Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libcxx/include/complex:247:
    In file included from /Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libcxx/include/sstream:174:
    In file included from /Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libcxx/include/ostream:131:
    In file included from /Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libcxx/include/ios:216:
    In file included from /Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libcxx/include/__locale:21:
    In file included from /Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/../../android/support/include/locale.h:39:
    /Users/user001/Documents/AndroidSDK/adt-bundle-mac-x86_64-20140702/sdk/ndk-bundle/platforms/android-8/arch-arm/usr/include/locale.h:55:1: warning: empty struct has size 0 in C, size 1 in C++ [-Wextern-c-compat]
    struct lconv { };
    ^
    In file included from jni/DetectionBasedTracker_jni.cpp:2:
    In file included from ../../../OpenCV-android-sdk/sdk/native/jni/include/opencv2/core/core.hpp:4883:
    ../../../OpenCV-android-sdk/sdk/native/jni/include/opencv2/core/operations.hpp:77:16: fatal error: 'ext/atomicity.h' file not found
          #include <ext/atomicity.h>
                   ^
    1 warning and 1 error generated.
    

0 个答案:

没有答案