当我使用Crystax ndk构建Ceres-Solver时,我改变了
APP_STL := c++_static
到
APP_STL := gnustl_static
对于gnustl_static与android上的OpenCV兼容,然后我有libceres.a,我将它复制到项目jni文件夹并将以下行添加到Applications.mk
然后我使用Crystax ndk运行ndk-build(我将Crystax文件夹添加到System PATH中)
LOCAL_LDLIBS += libceres.a
LOCAL_SRC_FILES += Test.cpp
使用Ceres的test.cpp的一部分如下:
struct CostFunctor {
template <typename T>
bool operator()(const T* const x, T* residual) const {
residual[0] = T(10.0) - x[0];
return true;
}
};
int main(int argc, char** argv) {
double x = 0.5;
const double initial_x = x;
Problem problem;
CostFunction* cost_function =
new AutoDiffCostFunction<CostFunctor, 1, 1>(new CostFunctor);
problem.AddResidualBlock(cost_function, NULL, &x);
Solver::Options options;
options.minimizer_progress_to_stdout = true;
Solver::Summary summary;
Solve(options, &problem, &summary);
return 0;
}
然后事情变得错误(发出的错误消息越多):
/home/panxiaoyu/ceres-solver/jni/../internal/ceres/miniglog/glog/logging.h:174: error: undefined reference to 'std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream(std::_Ios_Openmode)'
/opt/crystax-ndk/sources/cxx-stl/gnu-libstdc++/5/include/bits/basic_string.h:544: error: undefined reference to 'std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()'
/opt/crystax-ndk/sources/cxx-stl/gnu-libstdc++/5/include/sstream:766: error: undefined reference to 'std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const'
哪里错了?
我的ndk配置错误或者Crystax有错误吗?