安卓NDK:stoi / stof / stod / to_string不是'std'的成员

3

我正在Ubuntu 14.04 64位桌面上使用 Android NDK Standalone Toolchain编译mxnet(v0.9.3)合并文件,但遇到了一些错误。 第一个错误是:

arm-linux-androideabi-g++ -std=c++11 -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -fPIC -M -MT nnvm.o \
    -I `pwd`/../ -I `pwd`/../include \
    -D__MIN__=0 nnvm.cc > nnvm.d
arm-linux-androideabi-g++: error: unrecognized command line option '-msse2'

当我删除了'-msse2'选项并重新运行makefile时,它可以编译更多内容,但后来我遇到了像下面这样的新错误:
jni/../mxnet_predict-all.cc:2801:37: error: 'fopen64' was not declared in this scope
jni/../mxnet_predict-all.cc:21495:14: error: 'stoi' is not a member of 'std'
jni/../mxnet_predict-all.cc:30077:52: error: 'to_string' is not a member of 'std'
jni/../mxnet_predict-all.cc:34298:29: error: 'stof' is not a member of 'std'
jni/../mxnet_predict-all.cc:41383:56: error: 'stod' is not a member of 'std'
……

我应该做些什么来解决这些问题?

顺便说一下: 我的android-ndk版本是android-ndk-r13b。 为了创建独立的工具链,我按照以下步骤进行操作: $ python NDK/build/tools/make_standalone_toolchain.py --arch arm --api 21 --install-dir /tmp/my-android-toolchain

export PATH=$PATH:/tmp/my-android-toolchain/bin
export CXX=arm-linux-androideabi-g++
export CC=arm-linux-androideabi-gcc

更多信息:https://github.com/dmlc/mxnet/issues/4888


我的mxnet_predict-all.cc中的#include:

#if defined(__MACH__)
#include <mach/clock.h>
#include <mach/mach.h>
#endif

#if !defined(__WIN32__)
#include <sys/stat.h>
#include <sys/types.h>

#if !defined(__ANDROID__) && (!defined(MSHADOW_USE_SSE) || MSHADOW_USE_SSE == 1)
#include <emmintrin.h>
#endif

#endif

#include <algorithm>
#include <array>
#include <assert.h>
#include <atomic>
#include <cblas.h>
#include <cctype>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <condition_variable>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <dirent.h>
#include <errno.h>
#include <fstream>
#include <functional>
#include <inttypes.h>
#include <iostream>
#include <istream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <new>
#include <ostream>
#include <queue>
#include <random>
#include <regex>
#include <sched.h>
#include <set>
#include <sstream>
#include <stdbool.h>
#include <stddef.h>
#include <stdexcept>
#include <stdint.h>
#include <stdlib.h>
#include <streambuf>
#include <string>
#include <thread>
#include <time.h>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

你是否包含了需要使用这些函数的文件?例如,stoistring头文件中声明:你在mxnet_predict-all.cc中是否包含了#include <string> - rocambille
你是否正在使用GNU STL?如果是的话,请参考例如https://dev59.com/7mMl5IYBdhLWcg3w_rOD#18124627。 - Michael
@wasthishelpful 是的,我包含了<string>。我在我的问题中附上了mxnet_predict-all.cc的#includes部分,请检查一下。 - ROKIM
@Michael 我不太确定,因为我是个新手。看起来默认情况下使用的是libstdc++,这是否意味着我正在使用GNUSTL? - ROKIM
是的,这似乎确实是一个GNU STL库的问题。我使用选项“--stl = libc ++”重新构建了android-toolchain,并成功编译了它。 - ROKIM
2个回答

2

看起来是GNU STL库的问题。我使用选项“--stl = libc ++”重新构建了android-toolchain,并成功编译。


1

这是https://github.com/android-ndk/ndk/issues/82#issuecomment-236979264

它不会出现在r13中。 "修复"的方法是我们正在开发libc ++,因此gnustl变得不必要。 r14可能是完成它的时间。 这已经是r13的全部重点,但有很多中间任务需要完成它。

(这不是r13或r14中的内容,但实际上这就是我们正在为r15而工作的内容)

编辑:这在NDK r16中得到了修复。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接