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!