1. Using VMware to install Ubuntu13.10 32-bit virtual machine under Windows7 64-bit;
2. Download android-ndk32-r10-linux-x86.tar.bz2 from https://developer.android.com/tools/sdk/ndk/index.html ;
3, copy the android-ndk32-r10-linux-x86.tar.bz2 to Ubuntu/home/spring/neon folder, and unzip;
4, configure the environment variables: in the terminal input sudovi/etc/profile, open the profile file, at the end of this file add:
Export Ndkroot=/home/spring/neon/android-ndk-r10 (Note: absolute path)
Export path= $NDKROOT: $PATH
5, Save the profile file, restart Ubuntu;
6, input echo $PATH, there will be/home/spring/neon/android-ndk-r10;
7, input ndk-build, display ANDROIDNDK and other related information, indicating the success of the configuration ndk;
8. Install ARM-LINUX-GCC (Linux Platform cross-compilation tool based on ARM architecture): download from http://www.arm9.net/download.asp Arm-linux-gcc-4.4.3-20100728.tar.gz;
9, copy the arm-linux-gcc-4.4.3-20100728.tar.gz to Ubuntu/home/spring/neon folder, and unzip; Tarxvzf Arm-linux-gcc-4.4.3-20100728.tar.gz
10, configure the environment variable: in the terminal input sudo vi/etc/profile, open the profile file, at the end of this file add: exportpath= $PATH:/home/spring/neon/opt/friendlya Rm/toolschain/4.4.3/bin, save profile;
11, restart Ubuntu, in the terminal input arm-linum-gcc-v, if display GCC version 4.4.3 and other related information, the configuration is successful.
Sample code (HTTP://HILBERT-SPACE.DE/?P=22) Test.cpp:
void Reference_convert (uint8_t * __restrict dest, uint8_t * __restrict src, int n) { int i; for (i=0; i<n; i++) { int r = *src++;//load red int g = *src++;//load green int b = *src++;//Load Blue //Build Weighted average: int y = (r*77) + (g*151) + (b*28); Undo the scale by a and write to memory: *dest++ = (y>>8);} } void Neon_convert (uint8_t * __restrict dest, uint8_t * __restrict src, int n) { int i; uint8x8_t RFAC = Vdup_n_u8 (a); uint8x8_t GFAC = vdup_n_u8 (151); uint8x8_t BFAC = vdup_n_u8 (+); n/=8; for (i=0; i<n; i++) { uint16x8_t temp; uint8x8x3_t RGB = vld3_u8 (src); uint8x8_t result; temp = VMULL_U8 (rgb.val[0], RFAC); temp = VMLAL_U8 (temp,rgb.val[1], GFAC); temp = VMLAL_U8 (temp,rgb.val[2], BFAC); result = Vshrn_n_u16 (temp, 8); Vst1_u8 (dest, result); src + = 8*3; Dest + = 8; }}
12, execute the command: Arm-linux-gcc–g–c–os–fpic–mfloat-abi=softfp–mfpu=neon test.cpp
Ar–r libtest[android].a *.O successfully generated libtest[android].a static library.
There is another way, is no need to install ARM-LINUX-GCC, directly with the ANDROID-NDK can be, the following steps:
1, then the 7th step above;
2, add environment variable: in terminal input sudovi/etc/profile, open profile file, at last add:
Export Ndkbin=/home/spring/neon/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin ( Note: absolute path)
Export path= $NDKBIN: $PATH
3, save the profile file, restart Ubuntu;
4, input echo $PATH, there will be/home/spring/neon/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin
5, compile Test.cpp code: arm-linux-androideabi-gcc-i/home/spring/neon/android-ndk-r10/platforms/android-9/arch-arm/usr/ Include-c-os–mfloat-abi=softfp–mfpu=neon Test.cpp
Ar–r libtest[android].a *.O successfully generated libtest[android].a static library.