使用ndk-build进行编译时找不到OpenCV头文件

时间:2015-03-12 14:21:32

标签: android opencv android-ndk java-native-interface

当我尝试ndk-build我的项目时,我得到:

opencv/core/core.hpp: No such file or directory
     #include <opencv/core/core.hpp>
                                    ^

据我所见,我已正确配置所有内容:

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# OpenCV
OPENCVROOT:= /.../
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk

LOCAL_MODULE    := native_lib
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS +=  -llog -ldl

include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-8
APP_MODULES := native_lib

出了什么问题?我从命令行运行ndk-build

ndk版本10d,OpenCV版本2.4.10。

以下是编译命令的详细输出:

[armeabi] Compile++ thumb: native_lib <= jni_part.cpp
/Users/me/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++ -MMD -MP -MF /Users/me/App/app/src/main/obj/local/armeabi/objs/native_lib//Users/me/App/app/src/main/jni/jni_part.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I/Users/me/App/app/src/main/jni -I/Users/me/App/app/src/debug/jni -I/Users/me/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include -I/Users/me/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include -I/Users/me/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include/backward -I/Users/me/App/app/build/intermediates/ndk/debug -DANDROID  -Wa,--noexecstack -Wformat -Werror=format-security    -frtti -fexceptions  -I/Users/me/android-ndk-r10d/platforms/android-8/arch-arm/usr/include -c  /Users/me/App/app/src/main/jni/jni_part.cpp -o /Users/me/App/app/src/main/obj/local/armeabi/objs/native_lib//Users/me/App/app/src/main/jni/jni_part.o

1 个答案:

答案 0 :(得分:1)

您应该将OpenCV的include目录添加到LOCAL_C_INCLUDES,否则编译器将无法找到它们

LOCAL_C_INCLUDES := $(OPENCVROOT)/sdk/native/jni/include