簡體   English   中英

在JNI中創建c ++類的元素

[英]Create an element of a c++ class in JNI

我想創建一個自己的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:在函數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:在函數Java_com_example_telo3_Process_inicializar_1nativo:jni \\ nativo.cpp C / C ++問題

在您的Android.mk您應該擁有

LOCAL_SRC_FILES := nativo.cpp \
   Almacena.cpp \
   ... all other cpp files

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM