Skip to content Skip to sidebar Skip to footer

How To Compile C++11 Code With Android Ndk And Eclipse?

I'm using android NDK r8d, and eclipse Juno. I'm trying to compile C++ code which uses C++11 stuff like mutex, lock_guard, shared_ptr, etc. in a native android project in eclipse.

Solution 1:

Regarding your first question:

  1. Go to Project > Properties > C/C++ General / Paths and Symbols

  2. In the "Includes" tab, add the proper directory, e.g. /android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include

Regarding your second question, I'm also looking for an answer. It is absolutely not clear how to define the GXX_EXPERIMENTAL_CXX0X macro in Eclipse.

Some say that it should be "added as a predefined macro to the indexer", but it looks like we both could not find a way to implement that...

I have read elsewhere that it should be added to "C/C++ General / Paths and Symbols / Symbols / GNU C++" but I can't find the "Symbols / GNU C++" part in my version of Indigo.

Solution 2:

I find export an environment variable NDK_TOOLCHAIN_VERSION=4.8 before i start eclipse can solve this problem.

Eclipse use ndk's default toolchain version 4.6, if NDK_TOOLCHAIN_VERSION is not define, and gcc witch this version does not support all c++11's future like multithread and so on.

Post a Comment for "How To Compile C++11 Code With Android Ndk And Eclipse?"