Android Running Linux executable program

Source: Internet
Author: User

/**************************************************************************** * Android running Linux Executable program * Declaration: * 1. Linux executables can not be placed on the sdcard, will cause no permissions, it is strongly recommended to put in the */data/directory, my executable is placed in the/data/local/. * 2. The Linux executable is placed on the target machine via the adb.exe of the SDK, and the cmd command is as follows: * adb push <local file absolute path> <target file Absolute pa th> * Parameter Resolution: * 1. The absolute path of the local file absolute path:pc machine Linux executable; * 2. Target file absolute the absolute path of the Linux executable * in place of the path:android machine; * 3. You can use normal ARM-LINUX-GCC to generate a "static" executable program, or you can use the * NDK to generate executable programs that have been tested by everyone. * 2015-4-25 Saturday Sunny Shenzhen Nanshan Zengjianfeng ********************************************************** *****************/                \\\\\\\\\\\\\\\\Directory////////////// |A. Reference documentation:|Two. Test procedure buzz_test.c:|three. Android.mk:|four. Compile the test program:|Five. Where is Adb.exe:|Six. How to use ADB (take Windows 7 as an example): \\\\\\\\\\\\\\\\\\\\//////////////////A. Reference documentation:1. Write an executable program that runs directly on Android's Linux system-detecting CPU Capacity: http://blog.csdn.net/abnerchai/article/details/6830644    2. Android's ADB tool uses: http://www.cnblogs.com/devinzhang/archive/2011/12/17/2291396.htmlTwo. Test procedure buzz_test.c: #include<stdio.h>#include<fcntl.h>#defineBUZZ_ON 30#defineBuzz_off 31intMain (intargcChar**argv) {        inti =0; intRun_status =1; intBuzz_status =0; intBuzz_file = open ("/dev/buzz", O_RDWR); if(Buzz_file = =-1) {printf ("Open/dev/buzz failed...\n"); return-1; }         while(run_status) {Usleep ( +*2 ); I++; if( the==i) {run_status=0; }            ifI2==0) IOCTL (Buzz_file, buzz_on); ElseIOCTL (Buzz_file, Buzz_off);    } close (Buzz_file); } three. Android.mk:LOCAL_PATH:= $ (Call my-dir) include $ (clear_vars) Local_module:=buzz_test local_src_files:=buzz_test.c include $ (build_executable) four. Compile the test program:1. can use arm-linux-GCC compilation get Linux executable: Arm-LINUX-GCC Buzz_test.c-o Buzz_test-Static    2The Linux executable can be obtained using the NDK compilation:1Make sure your computer is configured with the Cygwin NDK environment; 2Create a JNI directory under the directory of the source program; 3. Copy the buzz_test.c android.mk to the JNI directory; 4the Cygwin jumps to 3 in the JNI upper level directory, also can be considered as Android engineering directory; 5. Run $ndk/ndk-build, which is generally done; 6. libs/armeabi/on a first-level directory of JNIbuzz_test executable file;            . ├─jni├─libs└─armeabi└─buzz_test--->finally we need the Linux executable file3for the current test results, the above method is optional; five. where Adb.exe: The SDK you downloaded platform-Tools folder, online said not necessarily in this folder, if you can not find, then search it:1.        Linux under use Find; 2. Windows 7 Open the SDK folder, the upper right corner of the box input Adb.exe, automatically find, I really do not know what the name of the place:) six. How to use ADB (for example, Windows 7):1. open windows cmd; 2. Jump to the folder where the Adb.exe is located; 3. ADB devices1. To see if there is currently a computer connected to the Android machine, this article only assumes that only one Android computer is connected to it. 2. cmd display results: List of devices attached 0123456789ABCDEF device4because there is only one Android device, here we can use the following command to transfer the Linux executable file:1. ADB push <local file absolute path> <target file Absolute path>parameter resolution:1. local file absolute the absolute path to the PATH:PC machine Linux executable; 2the. target file absolute the absolute path to the Linux executable that the path:android machine places; Maybe you're as surprised as I am, how did this happen, but she did it:)2. For example: ADB push D:/buzz_test/data/local/cmd Displays the result:1302KB/S <580120bytesinch 0.435s>5. Use ADB to enter Android devices:1. ADB shell (if you have only one Android device, you can do this, anyway I did it:)) CMD display result: [email protected]:/#--->The representative has entered the Android phone2. cd/data/local cmd display result: CD/data/Local3. ls cmd display result: LS buzz_test--->We push the incoming file BMP via ADB4. chmod777buzz_test cmd display result: chmod777buzz_test5. LS-al buzz_test cmd display result: LS-Al Buzz_test-RWXRWXRWX root root580120  --Geneva- +  -: thebuzz_test6. ./buzz_test---> will be able to execute your Linux executable here

Android Running Linux executable program

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.