To include c++ headers in Eclipse for Android NDK project(Mac)
An answer to this question on Stack Overflow.
Question
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 directoryAdded
android-ndk-r9/sources/cxx-stl/gnu-libstdc++/4.8/includeinC++ 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 forosdefines.h, I have copied all the files it is looking for , atlast it asked forbits/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?
Answer
Create a file called
Application.mkin the directoryprojet_dir/jni/(so it isprojet_dir/jni/Application.mk).Add the following line to that file
APP_STL:=stlport_static
If you run into a shared_ptr error, try using
APP_STL := gnustl_staticinstead.
(I had this exact same issue on Linux and the above resolved it for me.)