AndroidNdk

Summary: Author: 张亚飞 | 阅读时间: 2 minute read | Published: 2016-08-12
Filed under Categories: MarkDownTags: Tag,

NDK 官网


CrystaX NDK


不错的 NDK 文章


编译错误记录

集成 NDK 编译 Android 报错:

 /home/user5432/workspace/bitmapproj/obj/local/armeabi/objs-debug/mybitmap.o : In function Java_com_example_plasma_PlasmaView_renderPlasma
"undefined reference to AndroidBitmap_getInfo"
"undefined reference to AndroidBitmap_lockPixels"
"undefined reference to AndroidBitmap_unlockPixels"

gradleNDK 下添加如下依赖:

ndk {
    ldLibs "log","android", "jnigraphics" // 引用依赖的 ndk 库 ldLibs = ["android", "jnigraphics", <other ndk libraries you might need>]
}

Android.mk 添加如下依赖

`LOCAL_LDFLAGS += -ljnigraphics`

Reference:

出现 NEON 错误

Error:(31, 2) error: #error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h

error Unknown or unsupported ARM architecture

It would appear that at least as of Kitkat 4.4 (API 19), ARM devices are required to be at least ARMv7a:

MUST report, via android.os.Build.CPU_ABI, only one of the ABIs listed below
* armeabi-v7a
* x86
* mips
It's not altogether surprising that the API to follow 19 (Lollipop API 21) would drop support for ARMv5 completely. From what I've read, official builds of 4.4+ are always ARMv7a, but there are some custom builds for certain devices which run ARMv6.

So the fix is to target a lower API or target the armeabi-v7a architecture. Switching to v7a fixed this problem for me.

我的错误信息大概是 android-23/…/cpu-feature.h 中的错误,可能是最新的 ndk 暂不支持 cpu-feature.h 的 armeabi 平台编译库吧, 去掉 abiFilters 中的 armeabi 编译选项即可

abiFilters "armeabi-v7a" , "x86", "mips" //"armeabi", "armeabi-v7a" , "x86"

错误

Error:(208, 9) error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

C:\Users\yafei\AppDeveloperWorkspace\CoamAndroid\app\src\main\jni\audio.c
Error:(208, 9) error: 'for' loop initial declarations are only allowed in C99 or C11 mode
Information:(208, 9) use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
C:\Users\yafei\AppDeveloperWorkspace\CoamAndroid\app\src\main\jni\audio.c: In function 'Java_com_coam_ui_telegram_controller_TelegramMediaController_getWaveform2':
C:\Users\yafei\AppDeveloperWorkspace\CoamAndroid\app\src\main\jni\audio.c:692:5: error: 'for' loop initial declarations are only allowed in C99 or C11 mode

Telegram 相关


ogg 没有 config_types.h 错误

添加文件 rtn56u/user/flac-1.2.1/source/include/ogg/config_types.h


cpu-feature 问题


Comments

  • 牧马人 says: 2019-09-13 13:05:07

    江山代有才人出,各领风骚数百年.

  • 牧马人 says: 2019-09-13 13:05:16

    江山代有才人出,各领风骚数百年.

  • 牧马人 says: 2019-09-13 13:05:21

    江山代有才人出,各领风骚数百年.

Cor-Ethan, the beverage → www.iirii.com