操作系统:Linux
编译:NDK-Build
我尝试mlPack
从源代码编译时遇到错误。当我通过安装mlPack
及其依赖项(armadillo
,,,ensmallen
)运行代码时,代码运行良好boost
。但我正在尝试创建以下文件(,)和*.so
库的单个文件。并且在尝试时发生错误。*.a
mlpack_test.cpp
mlpack_test.hpp
mlPack
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);
}
错误
每当我尝试使用创建*.so
or*.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)