NDK构建opencv错误

时间:2017-11-09 02:08:34

标签: opencv build android-ndk

我使用NDK方式编译源代码遇到错误,我将opencv源代码复制到jni目录,准备好Android.mk和Application.mk以及源文件。 Mk文件,编译出了以下错误,也请给点建议,谢谢! ! !

操作系统:Ubuntu 17210 64bit opencv版本:3.3 android-ndk版本:14b

log:
[armeabi-v7a] Gdbserver      : [arm-linux-androideabi] libs/armeabi-v7a/gdbserver
[armeabi-v7a] Gdbsetup       : libs/armeabi-v7a/gdb.setup
[armeabi-v7a] Compile++ thumb: opencv <= perf_io_base64.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_addWeighted.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_convertTo.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_math.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_split.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_inRange.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_umat.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_stat.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_dft.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_abs.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_bitwise.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_cvround.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_compare.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_merge.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_mat.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_sort.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_main.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_norm.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_lut.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_reduce.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_dot.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_gpumat.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_arithm.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_minmaxloc.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_usage_flags.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_bufferpool.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_matop.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_gemm.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_arithm.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_dxt.cpp
[armeabi-v7a] Compile++ thumb: opencv <= perf_channels.cpp
[armeabi-v7a] Compile++ thumb: opencv <= cuda_host_mem.cpp
In file included from /home/jiangc/opencv3.3Ndk库/hello-jni/jni/core/src/cuda_host_mem.cpp:44:
In file included from /home/jiangc/opencv3.3Ndk库/hello-jni/jni/core/src/precomp.hpp:49:
In file included from /home/jiangc/opencv3.3Ndk库/hello-jni/jni/include/opencv2/core/utility.hpp:56:
In file included from /home/jiangc/opencv3.3Ndk库/hello-jni/jni/include/opencv2/core.hpp:52:
In file included from /home/jiangc/opencv3.3Ndk库/hello-jni/jni/include/opencv2/core/cvdef.h:189:
In file included from /home/jiangc/opencv3.3Ndk库/hello-jni/jni/include/opencv2/core/cv_cpu_dispatch.h:32:
In file included from /home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/emmintrin.h:27:
In file included from /home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/xmmintrin.h:27:
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:47:5: error: 
      use of undeclared identifier '__builtin_ia32_emms'; did you mean '__builtin_isless'?
    __builtin_ia32_emms();
    ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:47:5: note: 
      '__builtin_isless' declared here
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:47:25: error: 
      too few arguments to function call, expected 2, have 0
    __builtin_ia32_emms();
                        ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:64:19: error: 
      use of undeclared identifier '__builtin_ia32_vec_init_v2si'
    return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:81:12: error: 
      use of undeclared identifier '__builtin_ia32_vec_ext_v2si'
    return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
           ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:143:19: error: 
      use of undeclared identifier '__builtin_ia32_packsswb'
    return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:173:19: error: 
      use of undeclared identifier '__builtin_ia32_packssdw'
    return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:203:19: error: 
      use of undeclared identifier '__builtin_ia32_packuswb'
    return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:230:19: error: 
      use of undeclared identifier '__builtin_ia32_punpckhbw'
    return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:253:19: error: 
      use of undeclared identifier '__builtin_ia32_punpckhwd'
    return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:274:19: error: 
      use of undeclared identifier '__builtin_ia32_punpckhdq'
    return (__m64)__builtin_ia32_punpckhdq((__v2si)__m1, (__v2si)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:301:19: error: 
      use of undeclared identifier '__builtin_ia32_punpcklbw'
    return (__m64)__builtin_ia32_punpcklbw((__v8qi)__m1, (__v8qi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:324:19: error: 
      use of undeclared identifier '__builtin_ia32_punpcklwd'
    return (__m64)__builtin_ia32_punpcklwd((__v4hi)__m1, (__v4hi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:345:19: error: 
      use of undeclared identifier '__builtin_ia32_punpckldq'
    return (__m64)__builtin_ia32_punpckldq((__v2si)__m1, (__v2si)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:366:19: error: 
      use of undeclared identifier '__builtin_ia32_paddb'; did you mean '__builtin_arm_qadd'?
    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:366:19: note: 
      '__builtin_arm_qadd' declared here
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:366:40: error: 
      cannot initialize a parameter of type 'int' with an rvalue of type '__v8qi'
      (vector of 8 'char' values)
    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
                                       ^~~~~~~~~~~~
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:387:19: error: 
      use of undeclared identifier '__builtin_ia32_paddw'; did you mean '__builtin_arm_qadd'?
    return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:366:19: note: 
      '__builtin_arm_qadd' declared here
    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:387:40: error: 
      cannot initialize a parameter of type 'int' with an rvalue of type '__v4hi'
      (vector of 4 'short' values)
    return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
                                       ^~~~~~~~~~~~
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:408:19: error: 
      use of undeclared identifier '__builtin_ia32_paddd'; did you mean '__builtin_arm_qadd'?
    return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:366:19: note: 
      '__builtin_arm_qadd' declared here
    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
                  ^
/home/jiangc/android-ndk-r14b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/mmintrin.h:408:40: error: 
      cannot initialize a parameter of type 'int' with an rvalue of type '__v2si'
      (vector of 2 'int' values)
    return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
                                       ^~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [/home/jiangc/opencv3.3Ndk库/hello-jni/obj/local/armeabi-v7a/objs/opencv/core/src/cuda_host_mem.o] Error 1


Android.mk file
--------------------------------------------------------------------------------
LOCAL_PATH :=$(call my-dir)
ZLIB_PATH:=/home/jiangc/android-ndk-r14b/platforms/android-19/arch-arm/usr
include $(CLEAR_VARS)


LOCAL_MODULE := opencv

#源文件 mk 文件
include $(LOCAL_PATH)/core_source.mk
include $(LOCAL_PATH)/dnn_source.mk
include $(LOCAL_PATH)/features2d_source.mk
include $(LOCAL_PATH)/highgui_source.mk
include $(LOCAL_PATH)/imgcodecs_source.mk
include $(LOCAL_PATH)/imgproc_source.mk
include $(LOCAL_PATH)/ml_source.mk
include $(LOCAL_PATH)/objdetect_source.mk
include $(LOCAL_PATH)/photo_source.mk
include $(LOCAL_PATH)/stitching_source.mk
include $(LOCAL_PATH)/videoio_source.mk
include $(LOCAL_PATH)/video_source.mk
include $(LOCAL_PATH)/viz_source.mk
include $(LOCAL_PATH)/calib3d_source.mk
include $(LOCAL_PATH)/ts_source.mk

#include $(LOCAL_PATH)/cuda_source.mk

#包含源文件变量
LOCAL_SRC_FILES := $(CORE_SOURCE) \
                   $(DNN_SOURCE)     \
                   $(FEATURES2D_SOURCE)   \
                   $(HIGHGUI_SOURCE)    \
                   $(IMGCODECS_SOURCE)    \
                   $(IMAGEPROC_SOURCE)    \
                   $(ML_SOURCE)    \
                   $(OBJDETECT_SOURCE)    \
                   $(PHOTO_SOURCE)    \
                   $(STITCHING_SOURCE)   \
                   $(VIDEOIO_SOURCE)    \
                   $(VIDEO_SOURCE)    \
                   $(VIZ_SOURCE)       \
                   $(TS_SOURCE)\
                   $(CALIB3D_SOURCE)

                   #$(CUDAWARPING_SOURCE)  \
                   #$(CUDASTEREO_SOURCE)   \
                   #$(CUDAIMGPROC_SOURCE)    \
                   #$(CUDAOBJDETECT_SOURCE)   \
                   #$(CUDAFEATURES2D_SOURCE)   \
                   #$(CUDALEGACY_SOURCE)   \
                   #$(CUDALEGACY_SOURCE)    \
                   #$(CUDAARITHM_SOURCE)    \
                   #$(CUDAOPTFLOW_SOURCE)    \
                   #$(CUDACODEC_SOURCE)      \
#定义include文件位置
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/  \
                  $(ZLIB_PATH)/include

LOCAL_CPPFLAGS := -frtti -fexceptions 
LOCAL_LDLIBS += -llog -lz 

LOCAL_LDLIBS+= -L$(SYSROOT)/usr/lib 

include $(BUILD_SHARED_LIBRARY)

Application.mk文件

APP_OPTIM := release
APP_PLATFORM := android-19
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti 
APP_CPPFLAGS += -fexceptions  
APP_CPPFLAGS += -DANDROID
APP_ABI := armeabi-v7a



One of the mk source files
--------------------------------------------------------------------------------
CORE_SOURCE = core/perf/perf_io_base64.cpp\
core/perf/perf_addWeighted.cpp\
core/perf/perf_convertTo.cpp\
core/perf/perf_math.cpp\
core/perf/perf_split.cpp   \
core/perf/perf_inRange.cpp   \
core/perf/perf_umat.cpp   \
core/perf/perf_stat.cpp   \
core/perf/perf_dft.cpp   \
core/perf/perf_abs.cpp    \
core/perf/perf_bitwise.cpp   \
core/perf/perf_cvround.cpp    \
core/perf/perf_compare.cpp    \
core/perf/perf_merge.cpp    \
core/perf/perf_mat.cpp    \
core/perf/perf_sort.cpp   \
core/perf/perf_main.cpp    \
core/perf/perf_norm.cpp    \
core/perf/perf_lut.cpp    \
core/perf/perf_reduce.cpp    \
core/perf/perf_dot.cpp    \
core/perf/cuda/perf_gpumat.cpp   \
core/perf/perf_arithm.cpp    \
core/perf/perf_minmaxloc.cpp    \
core/perf/opencl/perf_usage_flags.cpp    \
core/perf/opencl/perf_bufferpool.cpp    \
core/perf/opencl/perf_matop.cpp    \
core/perf/opencl/perf_gemm.cpp     \
core/perf/opencl/perf_arithm.cpp   \
core/perf/opencl/perf_dxt.cpp    \
core/perf/opencl/perf_channels.cpp   \
core/src/cuda_host_mem.cpp   \
core/src/rand.cpp   \
core/src/lapack.cpp   \
core/src/parallel.cpp   \
core/src/lpsolver.cpp    \
core/src/stat.dispatch.cpp   \
core/src/matrix_decomp.cpp    \
core/src/trace.cpp    \
core/src/stat.cpp    \
core/src/cuda_stream.cpp   \
core/src/hal_internal.cpp    \
core/src/convert.avx2.cpp    \
core/src/convert.fp16.cpp   \
core/src/opengl.cpp    \
core/src/stl.cpp    \
core/src/copy.cpp    \
core/src/parallel_pthreads.cpp   \
core/src/alloc.cpp     \
core/src/directx.cpp    \
core/src/arithm.cpp     \
core/src/lda.cpp    \
core/src/va_intel.cpp    \
core/src/split.cpp    \
core/src/convert.sse4_1.cpp   \
core/src/gl_core_3_1.cpp    \
core/src/tables.cpp    \
core/src/out.cpp    \
core/src/cuda_info.cpp   \
core/src/mathfuncs.cpp     \
core/src/system.cpp     \
core/src/merge.cpp    \
core/src/mathfuncs_core.dispatch.cpp   \
core/src/matrix.cpp   \
core/src/command_line_parser.cpp   \
core/src/conjugate_gradient.cpp    \
core/src/softfloat.cpp     \
core/src/cuda_gpu_mat.cpp     \
core/src/persistence.cpp    \
core/src/ovx.cpp    \
core/src/array.cpp    \
core/src/dxt.cpp     \
core/src/glob.cpp     \
core/src/pca.cpp     \
core/src/kmeans.cpp    \
core/src/types.cpp    \
core/src/matmul.cpp    \
core/src/ocl.cpp   \
core/src/opencl/runtime/opencl_clamdfft.cpp  \
core/src/opencl/runtime/opencl_clamdblas.cpp   \
core/src/opencl/runtime/opencl_core.cpp    \
core/src/matop.cpp   \
core/src/convert.cpp   \
core/src/algorithm.cpp    \
core/src/downhill_simplex.cpp   \
core/src/umatrix.cpp    \
core/src/datastructs.cpp    \
core/test/test_misc.cpp    \
core/test/test_umat.cpp   \
core/test/test_eigen.cpp   \
core/test/test_ippasync.cpp   \
core/test/test_countnonzero.cpp   \
core/test/test_utils.cpp    \
core/test/test_rotatedrect.cpp   \
core/test/test_operations.cpp    \
core/test/test_math.cpp    \
core/test/test_io.cpp\
core/test/test_ptr.cpp\
core/test/test_hal_core.cpp\
core/test/test_mat.cpp\
core/test/test_main.cpp\
core/test/test_dxt.cpp\
core/test/test_concatenation.cpp\
core/test/ocl/test_matrix_expr.cpp    \
core/test/ocl/test_gemm.cpp    \
core/test/ocl/test_dft.cpp   \
core/test/ocl/test_channels.cpp   \
core/test/ocl/test_image2d.cpp   \
core/test/ocl/test_matrix_operation.cpp   \
core/test/ocl/test_arithm.cpp   \
core/test/test_intrin.cpp   \
core/test/test_downhill_simplex.cpp   \
core/test/test_rand.cpp    \
core/test/test_conjugate_gradient.cpp   \
core/test/test_arithm.cpp    \
core/test/test_ds.cpp   \
core/test/test_lpsolver.cpp   \
core/CMakeFiles/3.9.1/CompilerIdCXX/CMakeCXXCompilerId.cpp   \
core/misc/java/src/cpp/core_manual.cpp

1 个答案:

答案 0 :(得分:0)

这些是x86特定的内在函数。我真的怀疑能否为Android构建CUDA支持。可能只是从CORE_SOURCE删除该文件。