无法解析 Eclipse Type size_t 中的 Android NDK
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16284199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android NDK in Eclipse Type size_t could not be resolved
提问by ademar111190
I'm getting the follow error: "Type 'size_t' could not be resolved" on android ndk project, but I already added the library paths:
我在 android ndk 项目上收到以下错误:“无法解析类型‘size_t’”,但我已经添加了库路径:
/Users/ademar/android-ndk-r8e/platforms/android-8/arch-arm/usr/include
/Users/ademar/android-ndk-r8e/sources/cxx-stl/stlport/stlport
/Users/ademar/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.7/include
so i not understand why this error.
所以我不明白为什么会出现这个错误。
code where I get the error:
我收到错误的代码:
static inline bool simplejson_wcsnlen(const wchar_t *s, size_t n)
I added each one of headers described herebut still not working.
I Tried the follow:
我尝试了以下操作:
#include <string.h>
#include <jni.h>
#include <android/log.h>
#include <iostream>
#include <stdio.h>
extern "C" {
JNIEXPORT jstring JNICALL Java_xxx_getStringFromJNI(JNIEnv* env, jobject thiz, jstring param) {
size_t x;
return env->NewStringUTF("test");
}
}
and it also not work...
它也不起作用......
回答by amirkavyan
size_t is defined in stddef.h which is compiler specific. In order to add it to the include path you have to add the /toolchain//prebuilt//lib/gcc///include to your path.
size_t 在特定于编译器的 stddef.h 中定义。为了将它添加到包含路径中,您必须将 /toolchain//prebuilt//lib/ gcc///include 添加到您的路径中。
For example for building an android app on 64bit windows machine using ndk, you have to add <NDK-PATH>\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.8\include
to your path.
例如,要使用 ndk 在 64 位 Windows 机器上构建 android 应用程序,您必须添加<NDK-PATH>\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.8\include
到您的路径中。