Ich versuche, Android-App mit vorhandenen C++ - Code, der OpenCV verwenden, zu bauen. Aber Android NDK sagt, dass "undefined Verweis auf 'TestMath :: getHello()'"Undefinierter Verweis auf Funktion Android NDK
Hier mein Android.mk ist:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#opencv
OPENCVROOT := /mypath/OpenCV-android-sdk
OPENCV_CAMERA_MODULES := off
OPENCV_INSTALL_MODULES := off
OPENCV_LIB_TYPE := SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := CrossMath
LOCAL_SRC_FILES := com_testapp_recognition_TestMath.cpp
LOCAL_SHARED_LIBRARIES := -lopencv_java3
include $(BUILD_SHARED_LIBRARY)
Application.mk:
APP_ABI := all
APP_CPPFLAGS := -frtti -fexceptions -std=c++11
APP_STL := gnustl_static
APP_PLATFORM := android-16
com_testapp_recognition_TestMath. HPP:
#include <jni.h>
#include "CrossMath/TestMath.hpp"
#ifndef _Included_com_testapp_recognition_TestMath
#define _Included_com_testapp_recognition_TestMath
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jint JNICALL Java_com_testapp_recognition_TestMath_recognize(JNIEnv *, jobject, cv::Mat& originalImage);
#ifdef __cplusplus
}
#endif
#endif
com_testapp_recognition_TestMath.cpp:
#include "com_testapp_recognition_TestMath.hpp"
JNIEXPORT jint JNICALL Java_com_testapp_recognition_TestMath_recognize(JNIEnv *, jobject, cv::Mat& originalImage) {
return TestMath::getHello().size();
}
Und schließlich TestMath.cpp, die in Unterordner CrossMath befindet:
#include "TestMath.hpp"
namespace TestMath {
string getHello() {
return "Hello";
}
}
TestMath.hpp:
#ifndef TestMath_hpp
#define TestMath_hpp
#include <stdio.h>
#include <iostream>
#include "opencv2/core/core_c.h"
#include "opencv2/opencv.hpp"
#include "opencv2/highgui.hpp"
namespace TestMath {
string getHello();
}
Java-Klassen und andere Mitarbeiter definiert sind, überprüft Pfad und enthält in Dateien .
Fehler:
Error:(13) undefined reference to `TestMath::getHello()'
Bitte fügen Sie die vollständige und genaue Fehlermeldung hinzu. Ich sehe den Punkt von 'CrossMath/TestMath.hpp' nicht wirklich. Funktionsimplementierungen sollen nicht in Headerdateien platziert werden. – Michael
@Michael Es ist offensichtlich Tippfehler ... –
Was ist 'String' soll sein? 'std :: string'? Wenn ja, wo schließt du '' ein und wo meinst du, dass du willst, dass es 'string' vom' std' Namespace ist? –
Michael