Build an arm-Linux-GCC cross-compilation tool chain environment (Android native (JNI) Development Environment)

Source: Internet
Author: User

Environment:

Windows XP + VMware + RedHat (UBUNTU)

Note: The environment described in this article is also the development environment of Android native C (JNI ).

1. First download a cross-compilation tool chain version

Http://www.codesourcery.com/sgpp/lite/arm/portal/subscription3057 select the latest version to enter the download page, select the ia32 GNU/Linux compiler for Advanced packages

2, upload to/usr/local/and decompress tar jxvf arm-2010.09-50-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 to an arm-2010.09

3. Test. Go to the/usr/local/ARM-2010.09/bin directory and create a main. c file,

Main. C content

# Include <stdio. h>

Int main ()

{

Int I = 0;

Printf ("% d \ n", I );

Return;

}

Run./ARM-None-Linux-gnueabi-GCC main. c

No error is reported. Generate the. Out file.

Run./ARM-None-Linux-gnueabi-gcc-V

Show version 4.5.1

Yes.

Modify the path of the/etc/profile file and add the current directory/usr/local/ARM-2010.09-50/bin to the path.

Source/boot/. bashrc make the modification take effect immediately

Instance test:

Go to the working directory/home/Android/jnitest

Create File main. C, File Content

# Include <stdio. h>
Int main ()
{
Int I = 0;
Printf ("Hi ym012 % d \ n", I );
Return;
}

Arm-None-Linux-gnueabi-gcc-static main. C-o main
Start the android simulator, first create the/dev/sample directory, then upload the compiled main, and finally change the main to executable. The command is as follows:

ADB shell mkdir/dev/sample // create a directory in the simulator
ADB push main/dev/sample/main // upload the main file to/dev/sample/main

ADB shell chmod 777/dev/sample/main // modify it to an executable file

Go to the command line mode and enter the/dev/sample directory of the android simulator to execute Hello:

ADB Shell

# Cd/dev/sample

#./Hello // execute hello

The running result is as follows:

Hi ym012 0 _______________

Conclusion: Success!

Related Article

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.