Android ndk-build iostream:没有这样的文件或目录 [英] Android ndk-build iostream: No such file or directory

查看:33
本文介绍了Android ndk-build iostream:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 ndk-build 工具编译 cpp 文件时遇到问题(带有 cygwin 的 windows 7)当我尝试使用 #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

这是我的 Android.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_ROOTsourcescxx-stlgnu-libstdc++include)中有 iostream 文件,但我不知道如何告诉编译器在其中查找 iotream(和其他标准头文件)那个文件夹.

I have iostream file in android ndk folder (NDK_ROOTsourcescxx-stlgnu-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.

似乎我缺少一个或几个环境变量,或者一些编译器标志.

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.

这篇关于Android ndk-build iostream:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆