且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用android-ndk优化本机代码(速度优化)

更新时间:2023-02-10 16:41:04

APP_OPTIM:=发布

将行APP_OPTIM := release放入您的Application.mk文件

Put the line APP_OPTIM := release into your Application.mk file

ndk-build NDK_DEBUG = 0

只需将NDK_DEBUG=0作为参数传递给ndk-build脚本.定义APP_OPTIM := release后就不需要它.

Just pass the NDK_DEBUG=0 as a parameter to ndk-build script. You don't need it once you define APP_OPTIM := release.

-DNDEBUG

这应该进入您的LOCAL_CFLAGS:

LOCAL_CFLAGS += -DNDEBUG

LOCAL_CFLAGS + = -O2

这实际上不是必需的,因为Android NDK已经定义了-O2优化.

This is not required actually, since the Android NDK already defines -O2 optimization.