使用 ndk-build 编译时找不到 OpenCV headers
Can't find OpenCV headers when compiling with ndk-build
当我尝试 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
您应该将 OpenCV 的包含目录添加到 LOCAL_C_INCLUDES
否则编译器将找不到它们
LOCAL_C_INCLUDES := $(OPENCVROOT)/sdk/native/jni/include
当我尝试 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
您应该将 OpenCV 的包含目录添加到 LOCAL_C_INCLUDES
否则编译器将找不到它们
LOCAL_C_INCLUDES := $(OPENCVROOT)/sdk/native/jni/include