无法在android中包含iostream为什么?

前端之家收集整理的这篇文章主要介绍了无法在android中包含iostream为什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
安装了 android-ndk-r7,并尝试编译.cpp文件.
#include <iostream>

using namespace std;

int main ( int argc,char ** argv)
{

     cout <<"Hello World.."<<endl;

}

执行以下命令:
进入jni文件夹,然后执行

#ndk-build

得到以下错误

/home/jelari/Desktop/androidDevelopment/android-ndk-r7/DCF/jni/test1.cpp:1:20: error: iostream: No such file or directory
/home/jelari/Desktop/androidDevelopment/android-ndk-r7/DCF/jni/test1.cpp: In function 'int main(int,char**)':
/home/jelari/Desktop/androidDevelopment/android-ndk-r7/DCF/jni/test1.cpp:8: error: 'cout' was not declared in this scope
/home/jelari/Desktop/androidDevelopment/android-ndk-r7/DCF/jni/test1.cpp:8: error: 'endl' was not declared in this scope
make: *** [/home/jelari/Desktop/androidDevelopment/android-ndk-r7/DCF/obj/local/armeabi/objs/test1/test1.o] Error 1

我究竟做错了什么 ?

我的Android.mk文件如下所示:

# A simple test for the minimal standard C++ library
#

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := test1
LOCAL_SRC_FILES := test1.cpp
include $(BUILD_EXECUTABLE)

和Application.mk文件看起来像:

# Build both ARMv5TE and ARMv7-A machine code.
APP_ABI := armeabi armeabi-v7a

请指出错误

解决方法

所以答案很容易在SO上找到,这里是: @H_301_29@

By default,the C++ standard library is very minimal.

You need to set APP_STL in your Application.mk file.

I use:

APP_STL := gnustl_static

but you could have used system,stlport_static,stlport_shared,or
gnustl_static.

It’s documented under $NDK/docs/CPLUSPLUS-SUPPORT.html,and it’s a
little hidden,because the $NDK/documentation.html index file doesn’t
list it.

引自http://groups.google.com/group/android-ndk/browse_thread/thread/983c436239d48704?pli=1

原文链接:https://www.f2er.com/android/317155.html

猜你在找的Android相关文章