I got a _GLIBCXX_PERMIT_BACKWARD_HASH runtime error on android NDK when using hash_map

I keep porting my cocos2d-x project from win32 to android. I am using hash_map and now it causes a lot of problems.

I googled that I need to enable it from different sources on Android NDK and win32, for example:

#ifdef __GNUC__ #include <ext/hash_map> #else #include <hash_map> #endif 

but still, when I compile on NDK r7b, I got a compilation error:

D: / Developer / Android / android-ndk-r7b / sources / cxx-stl / gnu-libstdC ++ / include / ext / hash_map: 60: 30: error: backward_warning.h: There is no such file or directory

Cannot include file backward_warning.h

 #ifndef _GLIBCXX_PERMIT_BACKWARD_HASH #include "backward_warning.h" #endif 

How can i solve this?

+4
source share
3 answers

add macro to Android.mk file

 LOCAL_CFLAGS := -D_GLIBCXX_PERMIT_BACKWARD_HASH 
+4
source

The response bit is delayed, but here is a solution for others who have this problem. You just need to fix the way. Modify the gnu-libstdC ++ / include / ext / hash_map file and make the following changes. It will correctly display a build warning now instead of exiting with a missing file error.

Edit:

 #include "backward_warning.h" 

To:

 #include "../backward/backward_warning.h" 
0
source

The local solution is #include <backward/hash_map> instead of #include <ext/hash_map>

I just listened to this with Google as Issue 53404 , and the best solution I see includes editing your NDK:

Change sources/cxx-stl/gnu-libstdc++/Android.mk , find the line gnustl_exported_c_includes and add:

 $(LOCAL_PATH)/$(TOOLCHAIN_VERSION)/include/backward 

This makes the include paths used by the NDK consistent with those used by g ++ in its normal configuration.

Edit: Google applied this patch upstream; The fix was released with Android NDK Revision 9 in July 2013.

0
source

Source: https://habr.com/ru/post/1400303/


All Articles