Static link to the C file in ANDROID:
0. First, install the gcc-related compiler, which is not detailed in detail. The author uses mingw, or other compilers. Many installation instructions on the network are not described in this article.
1. Create a C code named "hello" and write the following content:
# Include <stdio. h>
Int main (){
Printf ("hello c !!! ");
Return 0;
}
2. Go to the directory specified in the c file, for example, d: \ test. Run the gcc hello. c or gcc hello. c-static-o hellostatic command to generate an executable exe file.
NOTE: If there is no new line end the file warning, you can press enter at the end of your programming.
3. Start the simulator and run the adb command (the adb command must be configured first, otherwise it may not support command errors). Create a c folder in the adb shell --> cd data --> mkdir c
4. Go to the directory specified in the c file, for example, d: \ test, Run D: \ test> adb push hellostatic.exe/data/c, and load the file into the c file,
5. Run the adb shell command to access the c file, for example: adb shell --> cd data --> cd c --> ls: Execute chmod 777 hellostatic.exe, for example, # chmod 777 hellostatic.exe (Set permissions)
6. continue to run the program through the./hellostatic.exe command. It will appear; 'Hello c !!! '
Summary: The executable files generated by static links are large and do not need to depend on any system library. Everything is self-contained.
Dynamic Link:
1. Run the command D: \ test> gcc-c Hello. c-o hello. o.
Because dynamic links are used, libraries of Linux in ANDROID must be used for links. These libraries are located in the/system/lib directory,
2. Go to the system folder and execute ls to list the files. One of them is the lib directory. Go to and list the files. There are also folders such as hw for various so files. To properly link the program, we copy all the library files in this directory (system/lib) to the local folder, run the adb pull command, such as C: \ Users \ Administrator> adb pull/system/lib d: \ LIB \ android_lib.
3
4. After the above image is executed, the following steps are similar to static links. Execute the command (install) adb push-> (control permission) adb shell chmod 777-> (run) adb shell/data/c/hello.exe