Android ndk-build iostream: No such file or directory

后端 未结 5 1048
难免孤独
难免孤独 2020-12-05 22:40

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/nati         


        
相关标签:
5条回答
  • 2020-12-05 23:17

    This works for me.

    LOCAL_STATIC_LIBRARIES +=  libstlport
    
    LOCAL_C_INCLUDES += external/stlport/stlport 
    LOCAL_C_INCLUDES += bionic
    
    0 讨论(0)
  • 2020-12-05 23:24

    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.

    0 讨论(0)
  • 2020-12-05 23:28

    Adding

    APP_PLATFORM := android-23
    

    Or whatever revision you use solved it for me.

    0 讨论(0)
  • 2020-12-05 23:29

    Just spent days to update my NDK from r10e to r20, there're several variables are changed.

    For NDK r10e

    Android.mk:

    include $(CLEAR_VARS)
    LOCAL_MODULE := main
    LOCAL_SRC_FILES := ./main.cpp   
    LOCAL_C_INCLUDES += $(LOCAL_PATH)/
    LOCAL_CPP_EXTENSION := .cxx .cpp .cc
    LOCAL_CPPFLAGS := -fexceptions -frtti
    LOCAL_CPPFLAGS += -std=c++11 -D__cplusplus=201103L
    include $(BUILD_EXECUTABLE)
    

    Application.mk:

    APP_ABI := all
    APP_STL := gnustl_static
    NDK_TOOLCHAIN_VERSION := 4.9
    APP_OPTIM := debug
    

    For NDK r20

    Android.mk:

    include $(CLEAR_VARS)
    LOCAL_MODULE := main
    LOCAL_SRC_FILES := ./main.cpp   
    LOCAL_C_INCLUDES += $(LOCAL_PATH)/
    LOCAL_CPP_EXTENSION := .cxx .cpp .cc
    LOCAL_CPPFLAGS := -fexceptions -frtti
    LOCAL_CPPFLAGS += -std=c++11 -D__cplusplus=201103L -DANDROID_STL=c++_shared
    include $(BUILD_EXECUTABLE)
    

    Application.mk:

    APP_ABI := all
    #In general, you can only use a static variant of the C++ runtime if you have one and only one shared library in your application.
    APP_STL := c++_static
    NDK_TOOLCHAIN_VERSION := clang
    APP_PLATFORM := android-23
    APP_OPTIM := debug
    

    and my main.cpp (including my bin_node.h):

    int main(int argc,char **argv) {   
    printf("****************** tree node ******************\n");
    amo::BinNode<int> root(0);
    amo::BinNode<int>* lchild1 = root.insertLeftChild(1);
    amo::BinNode<int>* rchild2 = root.insertRightChild(2);
    amo::BinNode<int>* lchild3 = lchild1->insertLeftChild(3);
    amo::BinNode<int>* rchild4 = lchild1->insertRightChild(4);
    amo::BinNode<int>* lchild5 = rchild2->insertLeftChild(5);
    amo::BinNode<int>* rchild6 = rchild2->insertRightChild(6);
    amo::BinNode<int>* lchild7 = lchild3->insertLeftChild(7);
    amo::BinNode<int>* rchild8 = lchild3->insertRightChild(8);
    amo::BinNode<int>* lchild9 = rchild6->insertLeftChild(9);
    amo::BinNode<int>* rchild10 = rchild6->insertRightChild(10);
    amo::BinNode<int>* lchild11 = rchild8->insertLeftChild(11);
    amo::BinNode<int>* rchild12 = rchild8->insertRightChild(12);
    
    printf("going to root.traversePre()\n");
    root.traversePre();
    printf("going to root.traversePreLoop()\n");
    root.traversePreLoop();
    printf("going to root.traversePreLoop2()\n");
    root.traversePreLoop2();
    printf("\n****************** main return ******************\n");
    return 0;}
    

    Run ndk-build and build an executable file

    For more source code and information for this, check my GitHub

    0 讨论(0)
  • 2020-12-05 23:41

    Update your android ndk to the latest one . I faced error in android ndk ver 5

    0 讨论(0)
提交回复
热议问题