OS:Linux
Compile: NDK-Build
I am facing error while I try to compile mlPack
from source. The code works fine when I run by installing the mlPack
and it's dependencies(armadillo
, ensmallen
, boost
). But I am trying to create a single *.so
and *.a
file of the following files(mlpack_test.cpp
, mlpack_test.hpp
) and the mlPack
library together. And the error occurs while trying that.
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);
}
Error
Whenever I try to create the *.so
or *.a
file using ndk-build
, the following error occurs:
The Android.mk
file is as following:
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)
All the files including library folders are in the LOCAL_PATH
: