Ubuntu under Android NDK installation

Source: Internet
Author: User

Method 1.

1.google directly download the NDK source code decompression can be, the current version is android-ndk-r9d

Configuring $ndk_home and $PATH

Export ndk_home=/xxx/android-ndk-r9d
Export path= $NDK _home: $PATH

2. Extract Toolchain

Reference: docs/standalone-toolchain.html

A. Viewing the target instruction set arm or x86 or MIPS
B. Configure the directory for the header and root files used by the GCC compilation $SYSROOT

sysroot= $NDK _home/platforms/android-18/arch-arm
Export Sysroot

C. Invoking the NDK compiler

$NDK _home/build/tools/make-standalone-toolchain.sh--platform=android-18--install-dir=/tmp/my-android-toolchain

[--arch=x86] defaults to arm

D. Setting up $PATH and $CC (equivalent to the usual GCC)

Export Path=/tmp/my-android-toolchain/bin: $PATH
Export CC=ARM-LINUX-ANDROIDEABI-GCC # or export Cc=clang
Export cxx=arm-linux-androideabi-g++ # or export cxx=clang++

3. You can use $cc-o Hello hello.c

4. Upload Hello to Emulator

can be transferred to/data/under: adb push hello/data/

If the download is available: adb pull xx xx

can also be uploaded to SDcard, but at this time only read access to SDcard, you need to activate the emulator SDcard, specific method: The SDK directory:mksdcard-l sdcard 100m/xx/sdcard.img Then add-sdcard sdcard.img to load your sdcard while running the emulator, then upload and download using the pull and push buttons in Eclipse's Ddms

5. Open Emulator: ADB shell

6. Running Hello:/data/hello

Method 2.

Export ndk_home=/xxx/android-ndk-r9d
Export path= $NDK _home: $PATH

Open Eclipse

import/$NDK _home/samples/hello-jni

Hellojni (right click)----Properties

Builders----NEW----Program:

main//////

Name:ndk_builder

Location:/bin/bash

Working Directory:/bin

Arguments:--login-c "Cd/xx/android-ndk-r9d/samples/hello-jni && $NDK _home/ndk-build"

refresh//////

Refresh Resources Upon completion

Build options//////

Click the last three options----Specify resources----Hello Jni

Ok

Up Ndk_builder to the first place

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.