User Tools

Site Tools


cs438:cs-438_compile_and_run_simple_c_programs_on_your_android_avd

Compile and Run Simple C Programs on Your Android AVD


Follow this tutorial after you complete the Compile And Run The Android Goldfish Kernel for Intel x86 tutorial.

1. Add linux-x86 Android Native Development Kit (NDK) compile toolchain path to $PATH:

    export PATH=/usr/local/android/sdk/prebuilt/linux-x86/toolchain/i686-linux-android-4.6/bin:$PATH

2. Set CC variable to the correct Android gcc compiler:

    export CC=i686-linux-android-gcc

3. Set CCOPTIONS variable to the correct values for Android compile:

    export CCOPTIONS="--sysroot /usr/local/android/ndk/platforms/android-16/arch-x86/ -mandroid"

4. Compile your program, e.g. helloworld.c:

    $CC $CCOPTIONS helloworld.c -o hello

5. Run your Intel-based AVD, if it's not already running:

6. Upload the compiled C program to the running AVD:

    adb push hello /data/local

7. Run the just-pushed C program on the AVD:

    adb shell
    
    (At the # prompt:)
    
    cd /data/local
    
    ./hello
    
    (Also try strace:)
    
    strace ./hello

8. Also, compile, push and run the following programs via adb on your AVDs. Push all compiled programs via adb to /data/local:


cs438/cs-438_compile_and_run_simple_c_programs_on_your_android_avd.txt · Last modified: 2013/11/01 00:15 by jchung

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki