Android ndk-build iostream: No such file or directory

39,848

Solution 1

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

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

Solution 2

This works for me.

LOCAL_STATIC_LIBRARIES +=  libstlport

LOCAL_C_INCLUDES += external/stlport/stlport 
LOCAL_C_INCLUDES += bionic

Solution 3

Adding

APP_PLATFORM := android-23

Or whatever revision you use solved it for me.

Share:
39,848
Andrey Zavarin
Author by

Andrey Zavarin

Updated on July 16, 2020

Comments

  • Andrey Zavarin
    Andrey Zavarin almost 4 years

    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
    

    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
    

    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)
    

    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.

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

  • Andrey Zavarin
    Andrey Zavarin over 12 years
    I got this line in Android.mk, you can see that in my post.
  • Mārtiņš Možeiko
    Mārtiņš Možeiko over 12 years
    You should put that line in APPLICATION.mk file, not ANDROID.mk
  • Gaetan
    Gaetan over 12 years
    Yep! APPLICATION.mk has a different role than ANDROID.mk, and it must be created at jni's root (-> projet_dir/jni/Application.mk). (thanks Martins)
  • inder
    inder almost 10 years
    You may run into shared_ptr error, so in that case use: APP_STL := gnustl_static
  • Roel
    Roel about 8 years
    What to do when you use Gradle 2.10 / experimental:0.6.0-alpha7 ?
  • IgorGanapolsky
    IgorGanapolsky almost 8 years
    What is bionic for??
  • IgorGanapolsky
    IgorGanapolsky almost 8 years
    I am using ndk in Android Studio 2.1.1. Still getting the same error.