NDK - include lib error

asked 2015-04-29 10:46:26 -0600

Nemesis gravatar image

I need your help because it drives me crazy. What cause my error?

The error is

jni/algorithm.cpp:4:33: fatal error: opencv2/core/core.hpp: No such file or directory  #include <opencv2/core/core.hpp>
                                 ^ compilation terminated. make: *** [obj/local/arm64-v8a/objs/algorithm/algorithm.o] Error 1

My algorithm.cpp is:

#include <jni.h>
#include <string.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc_c.h"

using namespace std;
using namespace cv;

extern "C"
{
    JNIEXPORT jlong JNICALL Java_com_example_hematoma_MainActivity_fce(JNIEnv *env, jobject obj, jlong matimage)
          {
              Mat *jni_image  = (Mat*) matimage;

              return (jlong)jni_image;

          }
}

My Android.mk is:

LOCAL_PATH := $(call my-dir)

include /home/nemesis/adt-bundle-linux-x86_64-20140702/OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk

include $(CLEAR_VARS)
LOCAL_MODULE := algorithm
LOCAL_SRC_FILES := algorithm.cpp

LOCAL_C_INCLUDE := /home/nemesis/adt-bundle-linux-x86_64-20140702/OpenCV-2.4.10-android-sdk/sdk/native/jni/include/opencv2/core/core.hpp
LOCAL_C_INCLUDE += /home/nemesis/adt-bundle-linux-x86_64-20140702/OpenCV-2.4.10-android-sdk/sdk/native/jni/include/
include $(BUILD_SHARED_LIBRARY)

Of course I have also Application.so but I dont mention it here because I think it dont cause the error.

The error occurs when ndk try to build .so

edit retag flag offensive close merge delete

Comments

Shouldn't you call CLEAR_VARS before including OpenCV.mk? You do not need to set LOCAL_C_INCLUDE manually (it is actually LOCAL_C_INCLUDES), because it will be modified inside OpenCV.mk.

Your file should look like this:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include /home/nemesis/adt-bundle-linux-x86_64-20140702/OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := algorithm
LOCAL_SRC_FILES := algorithm.cpp
include $(BUILD_SHARED_LIBRARY)

Also, as far as I know, arm64-v8 is not supported in OpenCV yet.

mshabunin gravatar imagemshabunin ( 2015-04-30 03:16:46 -0600 )edit

Thank you very much :) you are right. I have also asked here http://stackoverflow.com/questions/29... . It is already fixed. The problem was missing S in word INCLUDES

Nemesis gravatar imageNemesis ( 2015-05-01 07:54:07 -0600 )edit