error: implicit declaration of function 'posix_memalign' [-Werror=implicit-function-declaration]

采用NDK版本Android-21编译的文件在android-21以下版本(4.4.2)可能出现以下问题:

error: undefined reference to 'atof'

参考:https://code.google.com/p/android/issues/detail?id=77861

When i use NDK r10b build success


APP_ABI := armeabi-v7a-hard
APP_PLATFORM := android-19
but when use NDK r10c, platform targe android-21, compile ok, but run error: dlopen failed: cannot locate symbol "atof" referenced
APP_ABI := armeabi-v7a-hard

APP_PLATFORM := android-21


解决办法:

下载并修改NDK中API 17,18,19中的libstd.h文件

下载地址:unzip -v posix_memalign_decl_17_18_19.zip

Ubuntu下操作方法:

unzip -v posix_memalign_decl_17_18_19.zip 

 Archive: posix_memalign_decl_17_18_19.zip Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ---- 5420 Defl:N 1993 63% 2014-10-22 10:38 85fa17d2 platforms/android-17/arch-arm/usr/include/stdlib.h 5420 Defl:N 1993 63% 2014-10-22 10:38 85fa17d2 platforms/android-17/arch-mips/usr/include/stdlib.h 5420 Defl:N 1993 63% 2014-10-22 10:38 85fa17d2 platforms/android-17/arch-x86/usr/include/stdlib.h 5420 Defl:N 1993 63% 2014-10-22 10:38 85fa17d2 platforms/android-18/arch-arm/usr/include/stdlib.h 5420 Defl:N 1993 63% 2014-10-22 10:38 85fa17d2 platforms/android-18/arch-mips/usr/include/stdlib.h 5420 Defl:N 1993 63% 2014-10-22 10:38 85fa17d2 platforms/android-18/arch-x86/usr/include/stdlib.h 5420 Defl:N 1993 63% 2014-10-22 10:38 85fa17d2 platforms/android-19/arch-arm/usr/include/stdlib.h 5420 Defl:N 1993 63% 2014-10-22 10:38 85fa17d2 platforms/android-19/arch-mips/usr/include/stdlib.h 5420 Defl:N 1993 63% 2014-10-22 10:38 85fa17d2 platforms/android-19/arch-x86/usr/include/stdlib.h -------- ------- --- ------- 48780 17937 63% 9 files

此外,还可以在platform/android-19/arch-arm/usr/include下将stdlib.h文件添加

<span style="font-size:18px;">extern int posix_memalign(void **memptr, size_t alignment, size_t size);</span>




你可能感兴趣的:(android,NDK,移植)