的Andr​​oid NDK建造的iostream:没有这样的文件或目录文件、目录、oid、Andr

2023-09-04 04:36:03 作者:二、也是一种境界

我有问题,编译CPP文件中使用(与Cygwin的Windows 7中)NDK​​,构建工具 当我尝试编译的#include CPP文件出现错误:

I'm having problem with compiling cpp file using ndk-build tool (windows 7 with cygwin) Error appears when I try to compile cpp file with #include:

jni/native.cpp:5:20: error: iostream: No such file or directory

下面是我的cpp文件:

Here is my cpp file:

#include <jni.h>
#include <string.h>
#include <stdio.h>
#include <android/log.h>
#include <iostream>

#define DEBUG_TAG "NDK_SampleActivity"
#define  LOG_TAG    "hellojni"
#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)


#ifdef __cplusplus
extern "C" {
#endif

void Java_com_test_ndk_SampleActivity_helloLog(JNIEnv* env, jobject thisobj, jstring logThis)
{
    jboolean isCopy;

    const char * szLogThis = env->GetStringUTFChars(logThis, &isCopy);

    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:LC: [%s]", szLogThis);

    env->ReleaseStringUTFChars(logThis, szLogThis);
}



#ifdef __cplusplus
}
#endif

和这里是我的Andr​​oid.mk文件:

And here is my Android.mk file:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

APP_STL:=stlport_static 

LOCAL_LDLIBS := -llog

LOCAL_MODULE    := swingbyte-android

LOCAL_SRC_FILES := native.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include-all
include $(BUILD_SHARED_LIBRARY)

我在Android的NDK文件夹(NDK_ROOT \来源\ CXX-STL \ GNU-的libstdc ++ \含)的iostream文件,但我没有任何想法如何告诉编译器去寻找iotream(和其他非标准的头文件)该文件夹。

I have iostream file in android ndk folder (NDK_ROOT\sources\cxx-stl\gnu-libstdc++\include) but I don't have any idea how to tell compiler to look for iotream (and other standart header files) in that folder.

这似乎是我缺少一个或一些环境变量,或者一些comiler标志。

It seems to that I'm missing one or few environment variables, or some comiler flags.

推荐答案

我觉得APP_STL:= stlport_static,必须在Application.mk文件

I think "APP_STL:=stlport_static" must be in Application.mk file.

创建Application.mk文件,并写入APP_STL:= stlport_static,它

Create a "Application.mk" file and write "APP_STL:=stlport_static" in it.