-- Build a visual development and debugging environment for Android native with code: bocok + ndk
I remember that the last series written to Android native was last year's 6.1, and it has been more than a year in the past. Although Android is very popular, why does Google still not launch a complete ndk development debugging environment today ?! I believe that more companies will use the underlying C/C ++ APIs to develop or transplant their products in the future. After all, through a layer of JNI (although there is a legendary 2.2 JIT Technology) how much will lead to a loss of efficiency!
Code: blocks I will not mention it any more. It is a very good open-source cross-platform C/C ++ development tool with active developers and forums. We recommend you download the version of "nightly: http://forums.codeblocks.org/index.php/board,20.0.html for development.
For the download and code: blocks configuration of the source code required for Android, refer to the previous blog:
- Android native C Development: toolchain environment setup (refer only to source code download and cygwin-related content)
- Android native C Development 10: development with code: blocks (refer only to the download configuration of code: blocks)
The downloaded source code directory should be shown in:
Of course, if you have any conditions, you can download all the source code for research. However, for basic native development, it is almost enough to have these source code and header files.
Ndk is assumed to download the latest r4b version: Latest
Please install the new version 1.7 for cygwin. I have not tested the old version. For installation instructions, refer to every blog listed. Install make and python2.5. (Be sure to Install Version 2.5, but not 2.6) it should be similar.
The following code starts: blocks + ndk configuration. Open codeblocks and select "Settings-> compiler and debugger... ", select" GNU arm GCC compiler "in the pop-up window, of course, you can also copy a new one, but to facilitate the use of this, then perform the following settings:
- Set Compiler's installation directory on the toolchain executables page to the directory under ndk: D: \ android-ndk-r4b \ build \ prebuilt \ windows \ arm-eabi-4.4.0 (4.2.1 is also available );
- All arm-ElfChange -xxx.exe to arm-Eabi-Xxx.exe;
- On the "toolchain executables" page, "additional paths" is added to the bin directory of cygwin. Because toolchain is built with cygwin, cygwin Runtime Library is required, such as "D: \ cygwin \ bin ".
For example:
Select the "compiler" page on the "search directories" Page and add the following directory to the list (assuming that the ndk is decompressed to the D: \ android-ndk-r4b directory, Android source code is downloaded to D: \ Android \ source directory ):
- D: \ android-ndk-r4b \ build \ platforms \ Android-8 \ arch-Arm \ USR \ include
- D: \ Android \ source \ frameworks \ base \ include
- D: \ Android \ source \ System \ core \ include
- D: \ Android \ source \ hardware \ libhardware \ include
- D: \ Android \ source \ external \ skia \ include \ Core
For example:
Add the library file directory of Android 2.1 to the "linker" Page: D: \ Android \ libs_2.1. For how to download library files using busybox, refer to the blog of "build toolchain environment.
With the built-in GDB ndk, debugging may have some problems, you can download the gdb source code to compile or download NVIDIA tegra Debugger: http://developer.download.nvidia.com/tegra/files/tegra-gdb-20100430.zip
After decompression, copy the files \ prebuilt \ windows \ arm-eabi-gdb.exe to the Directory D: \ android-ndk-r4b \ build \ prebuilt \ windows \ arm-eabi-4.4.0 \ bin, overwrite the original file, this is the latest Android 7.15 version of GDB, which solves many problems related to cygwin directory settings, and is easier to use than the 6.8 version of GDB that ndk is carrying.
Now you can start to compile and debug the program. The steps are as follows:
- Start the android simulator to ensure the normal operation of the ADB shell;
- Create an android arm project (a demo project: ftest.zip has been uploaded), select debug and compile, and upload the file to the simulator;
- Run the following command on the command line:ADB forward TCP: 1234 TCP: 1234To switch the local port and the android simulator port;
- Run ADB shell in the command line and run it after entering the command line of the simulator:Gdbsever 10.0.2.2: 1234 program_name(Program_name is your debuggable program name );
- In code: blocks, set the breakpoint, start debugging, and set the project properties as follows (right-click the project and select "properties... in the pop-up window, set as follows:
From http://blog.sina.com.cn/s/blog_4a0a39c30100l324.html