1

操作系统:Linux

编译:NDK-Build

我尝试mlPack从源代码编译时遇到错误。当我通过安装mlPack及其依赖项(armadillo,,,ensmallen)运行代码时,代码运行良好boost。但我正在尝试创建以下文件(,)和*.so库的单个文件。并且在尝试时发生错误。*.amlpack_test.cppmlpack_test.hppmlPack

mlPack_test.hpp

#include <iostream>
#include <string>
#include "mlpack/core.hpp"
#include "mlpack/methods/random_forest/random_forest.hpp"
#include "mlpack/methods/decision_tree/random_dimension_select.hpp"
#include "mlpack/core/cv/k_fold_cv.hpp"
#include "mlpack/core/cv/metrics/accuracy.hpp"
#include "mlpack/core/cv/metrics/precision.hpp" 
#include "mlpack/core/cv/metrics/recall.hpp"

using namespace arma;
using namespace mlpack;
using namespace mlpack::tree;
using namespace mlpack::cv;

using namespace std;

void Test();

mlPack_test.cpp

#include "mlpack_test.hpp"

void Test()
{
    string save_model_path = "model.bin";

    string sample = "1265,0,0,0,1,0,0,0,0,1,0,0,1,0,0,1,1,0,0";
    mat dataset(sample);
    Row<size_t> labels;
    labels = conv_to<Row<size_t>>::from(dataset.row(dataset.n_rows - 1));
    dataset.shed_row(dataset.n_rows - 1);

    const size_t numClasses = 5;
    const size_t minimumLeafSize = 5;
    const size_t numTrees = 50;

    RandomForest<GiniGain, RandomDimensionSelect> rf;
    rf = RandomForest<GiniGain, RandomDimensionSelect>(dataset, labels,
        numClasses, numTrees, minimumLeafSize);

    Row<size_t> predictions;
    rf.Classify(dataset, predictions);
    const size_t correct = arma::accu(predictions == labels);
    cout << "\nTraining Accuracy: " << (double(correct) / double(labels.n_elem))<<endl;
    mlpack::data::Save(save_model_path, "model", rf, false);

}

错误

每当我尝试使用创建*.soor*.a文件ndk-build时,都会发生以下错误:

在此处输入图像描述 在此处输入图像描述

Android.mk文件如下:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni-prebuilt
CODE_PATH := .
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := mlpack_test.cpp
include $(BUILD_SHARED_LIBRARY)

包括库文件夹在内的所有文件都在LOCAL_PATH在此处输入图像描述

4

1 回答 1

0

该问题已通过在 Android.mk 文件中使用 -frtti 和 -exception CPP 标志得到解决

于 2022-03-02T02:30:14.023 回答