简体   繁体   中英

To include c++ headers in Eclipse for Android NDK project(Mac)

I'm working on an Android NDK project in which I have to use functionalities which needs c++ header files such as iostream , sstream , etc,. I have already did this in linux by adding /usr/include/c++/4.7.. in C++ Paths & Symbols tab. But still din't find a way to do this in Mac. I have tried the following:

  • I have simply included iostream header #include<iostream> , it shows the following error while build using ndk-build, fatal error: iostream: No such file or directory

  • Added android-ndk-r9/sources/cxx-stl/gnu-libstdc++/4.8/include in C++ Paths and Symbols->Includes tab->cpp , It doesn't change anything.

  • In my Android.mk file,

      LOCAL_C_INCLUDES := android-ndk-r9/sources/cxx-stl/gnu-libstdc++/4.8/include 

    it gave the following error:

    fatal error: bits/c++config.h: No such file or directory

    I have also tried adding prebuilt shared library in Android.mk file , which gave the same error.

  • Then made a search for the file bits/c++config.h , copied it in to the actual place it is looking for, it shows the same error for osdefines.h , I have copied all the files it is looking for , atlast it asked for bits/memoryfwd.h , but I can't find the file anywhere in my Mac.

What is the actual problem here? What should I do to include those headers in cpp files in my Android NDK project?

  1. Create a file called Application.mk in the directory projet_dir/jni/ (so it is projet_dir/jni/Application.mk ).

  2. Add the following line to that file

     APP_STL:=stlport_static 
  3. If you run into a shared_ptr error, try using APP_STL := gnustl_static instead.

(I had this exact same issue on Linux and the above resolved it for me.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM