我想创建一个自己的c ++类的元素。 我的JNI功能:
JNIEXPORT void JNICALL Java_com_example_telo3_Process_inicializar_1nativo
(JNIEnv *, jobject){
Almacena almacena;
}
Almacena是一个c ++类:
#pragma once
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
class Almacena
{
private:
std::vector<Rect> myfaces;
std::vector<Rect> myeyes_r;
std::vector<Rect> myeyes_l;
std::vector<Rect> mynoses;
std::vector<Rect> mymouths;
Point2f P0;
Point2f P1;
Point2f P2;
Point2f P3;
public:
Almacena(void);
~Almacena(void);
void set_faces(std::vector<Rect> faces);
void set_eyes_r(std::vector<Rect> eyes_r);
void set_eyes_l(std::vector<Rect> eyes_l);
void set_noses(std::vector<Rect> noses);
void set_mouths(std::vector<Rect> mouths);
void set_P0(Point2f aux);
void set_P1(Point2f aux1);
void set_P2(Point2f aux2);
void set_P3(Point2f aux3);
std::vector<Rect> get_faces();
std::vector<Rect> get_eyes_r();
std::vector<Rect> get_eyes_l();
std::vector<Rect> get_noses();
std::vector<Rect> get_mouths();
Point2f get_P0();
Point2f get_P1();
Point2f get_P2();
Point2f get_P3();
};
我该怎么办?因为如果我喜欢我的代码,就会出现这些错误:
未定义引用'Almacena :: ~Almacena()'telo3第41行,外部位置:C:\ Users \ telo \ Desktop \ ANDROID \ android-ndk-r8d \ toolchains \ arm-linux-androideabi-4.6 \ prebuilt \ windows \ arm-linux-androideabi \ bin \ ld.exe:。\ obj \ local \ armeabi \ _ objs \ nativo \ nativo.o:in function Java_com_example_telo3_Process_inicializar_1nativo:jni \ nativo.cpp C / C ++问题
未定义引用'Almacena :: Almacena()'telo3第41行,外部位置:C:\ Users \ telo \ Desktop \ ANDROID \ android-ndk-r8d \ toolchains \ arm-linux-androideabi-4.6 \ prebuilt \ windows \ arm-linux-androideabi \ bin \ ld.exe:。\ obj \ local \ armeabi \ objs \ nativo \ nativo.o:in function Java_com_example_telo3_Process_inicializar_1nativo:jni \ nativo.cpp C / C ++问题
答案 0 :(得分:0)
在Android.mk
你应该
LOCAL_SRC_FILES := nativo.cpp \
Almacena.cpp \
... all other cpp files