【问题标题】:std::strtoull not recognized under my JNI NDK environment在我的 JNI NDK 环境下无法识别 std::strtoull
【发布时间】:2013-12-11 12:26:10
【问题描述】:

我通过使用 JNI 在 android 项目下使用了一些 c++ 代码。

但它总是会发出警告说:

jni/sample.cpp: In function 'int Java_com_android_mymapsforge_create(JNIEnv*, jo
bject)':
jni/sample.cpp:78:14: error: 'strtoull' is not a member of 'std'
jni/sample.cpp:78:14: note: suggested alternative:
C:/TDDOWNLOAD/adt-bundle-windows-x86_64-20130729/ndk/android-ndk-r9/platforms/an
droid-14/arch-arm/usr/include/stdlib.h:66:27: note:   'strtoull'
make: *** [obj/local/armeabi/objs/ann/sample.o] Error 1

但是,如果我包含 stdlib.h,它仍然有错误 toast。我的android.mk文件内容是这样的:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../ 

LOCAL_MODULE    := libann
LOCAL_LDLIBS    := -llog

NDK_TOOLCHAIN_VERSION := clang
LOCAL_CPPFLAGS += -std=c++11

LOCAL_SRC_FILES := \
    ANN.cpp \
    bd_pr_search.cpp \
    bd_tree.cpp \
    kd_pr_search.cpp \
    kd_split.cpp \
    kd_util.cpp \
    bd_fix_rad_search.cpp \
    bd_search.cpp \
    brute.cpp \
    kd_fix_rad_search.cpp \
    kd_search.cpp \
    kd_tree.cpp \
    kd_dump.cpp \
    perf.cpp\
    sample.cpp

include $(BUILD_SHARED_LIBRARY)

而我的 Application.mk 是这样的:

# The ARMv7 is significanly faster due to the use of the hardware FPU
APP_ABI := armeabi armeabi-v7a
#APP_ABI := armeabi
APP_OPTIM := release
#APP_OPTIM := debug
#APP_STL := stlport_static
APP_STL := gnustl_static

每当我将 APP_STL 标志更改为 stlport_static、stlport_shared、gnustl_shared 时。

它仍然有错误吐司,

大家有类似的问题吗?

还有一点,我的ndk版本是android-ndk-r9

【问题讨论】:

  • #include <cstdlib>了吗?

标签: java android c++ android-ndk


【解决方案1】:

你包括<cstdlib>吗?标头<cstdlib> 应声明std::strtoull,而<stdlib.h> 应声明strtoull,但不带std::

【讨论】:

    猜你喜欢
    • 2021-02-13
    • 2013-03-29
    • 2013-09-30
    • 1970-01-01
    • 2021-02-07
    • 1970-01-01
    • 2016-12-13
    • 2019-12-03
    相关资源
    最近更新 更多