使用ndk gcc编译

半年用一次,每次用都得现查一遍。

这里记录一下ndk中使用gcc编译直接跑在android上的二进制程序

先直接生成GNU Android Toolchain,然后就可以直接使用gcc来编译了,不必使用ndk-build,也免去了一堆配置文件的要求。

$NDK/build/tools/make-standalone-toolchain.sh --toolchain=arm-linux-androideabi-4.8 --platform=android-19 --install-dir=/opt/ndk_toolchain

生成后直接设置是否可用:

echo “main(){}” | /opt/ndk_toolchain/bin/arm-linux-androideabi-gcc -x c –

没有报错,即toolchain环境已经配置好。

 

生成的文件在虚拟器中测试时,注意各家的adb文件互相冲突。比如pp助手的adb就会占用端口,需要提前查看下是否存在后台进程,存再则杀掉。

夜神则直接使用nox_adb来连接。

 

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /opt/wordpress/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048