且构网

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

如何编译C code。使用NDK为Android设备(ARM)?

更新时间:2021-07-08 01:56:21

您说得对,我犯了一个错误,我什至没有测试它,并给了我
同样的错误,是由于主的切入点,因为这还没有
改变,但我希望这对你的作品。反正检查符号表纳米,
在实时执行strace的,你甚至可以用gdbserver的。

You're right, I made a mistake, I had not even tested it and gave me the same error, is due to the entry point of the "main", as this has not changed but I hope this works for you. Anyway check the symbol table "nm", the real-time execution "strace", you can even use gdbserver.

#include <stdio.h>
int main (int argc, char *argv[])
{
        printf ("hello world");
        return 0;
}


export NDK_ROOT=your_ndk_path
export PATH=$NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin:$PATH
export CC=arm-linux-androideabi-gcc
export LD=arm-linux-androideabi-ld
arm-linux-androideabi-gcc -I$NDK_ROOT/platforms/android-18/arch-arm/usr/include -Wl,-rpath-link=$NDK_ROOT/platforms/android-18/arch-arm/usr/lib -Wl,-L$NDK_ROOT/platforms/android-18/arch-arm/usr/lib -Wl,-lc -o test test.c

If ld return with erros like "... ld: error: cannot open... : No such file or directory"
try this for your losed files:
ln -s $NDK_ROOT/platforms/android-18/arch-arm/usr/lib/crtend_android.o
ln -s $NDK_ROOT/platforms/android-18/arch-arm/usr/lib/crtbegin_dynamic.o