iostream: No such file or directory

2,642 views
Skip to first unread message

Ian Clévy

unread,
Sep 21, 2011, 3:52:56 AM9/21/11
to android-ndk
Hello all,

I'm just starting out with the ndk, so this may be a silly
question ;).

I can't include iostream.h.

All the threads I've found that deal with this issue say to *just* add
APP_STL := gnustl_static into Application.mk, and I have done that.

I also tried ndk-clean, and deleting obj and lib manually, and ndk-
build -B.

This doesn't look like a link error, the compiler just can't find the
header file when i run ndk-build, as if I hadn't told it where to look
for them.

here is some code :

Game.c

#include <string.h>
#include <jni.h>
#include <stdio.h>

#include <iostream>

//I know i don't use iostream yet, but here is the rest of the file...
jstring Java_com_test_TestActivity_invokeNativeFunction(JNIEnv* env,
jobject javaThis)
{
char sTest[128];
sprintf( sTest, "HelloWorld" );
return (*env)->NewStringUTF(env, sTest);
}

-----------------------------------

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := Game
LOCAL_SRC_FILES := Game.c

include $(BUILD_SHARED_LIBRARY)

-----------------------------------

Application.mk

APP_STL := gnustl_static


All three files are in the jni folder of my project.

I'm using Windows + cygwin + eclipse.

The error ndk-build gives me is : error : iostream: No such file or
directory

Any ideas ?

Ian

Ronnie van Aarle

unread,
Sep 21, 2011, 3:49:32 PM9/21/11
to android-ndk
I think, when you're programming in C, you should say

#include <iostream.h>

unlike C++ that just accepts

#include <iostream>

Good luck.

Ian Clevy

unread,
Sep 21, 2011, 5:18:48 PM9/21/11
to andro...@googlegroups.com
Thanks for the reply.

I didn't change anything though :-).

The iostream file found in <ndk root>/sources/cxx-stl/gnu-libstd++/include doesn't have the .h.

There is also a readme file in gnu-libstd++ that says that all i need to do is add gnustl_static to my Application.mk. The readme also say something about sometimes having to rebuild the libs. Bit the libs are there...!

I've spent most of today on this thing now...i can't figure out what is wrong :-(

Best regards
Ian

> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>

Tim Mensch

unread,
Sep 21, 2011, 5:24:48 PM9/21/11
to andro...@googlegroups.com
Your file is a .c file. <iostream> is a C++ header. You can't include it
from a C file.

Make it a .cpp file instead.

Tim

Ian Clévy

unread,
Sep 22, 2011, 3:32:15 AM9/22/11
to android-ndk
Yes! That worked, I knew it what something silly that I hadn't thought
of :) Thankyou.

ian
Reply all
Reply to author
Forward
0 new messages