我使用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时。
它仍然有错误toast,
有没有类似的问题?
还有一点,我的ndk版本是android-ndk-r9
是否包含<cstdlib>
?标头<cstdlib>
应声明std::strtoull
,而<stdlib.h>
应声明不带std::
的strtoull
。