Environment:
CentOS 1, 5.4
[Root @ localhost bin] # cat/etc/redhat-release
CentOS release 5.4 (Final)
[Root @ localhost bin] # uname-
Linux localhost. localdomain 2.6.18-164. el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux
VMware 9.0.1 build-894247
I. preparations:
1. Download ndk
Http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86.tar.bz2
2. Download adt
Http://dl.google.com/android/adt/adt-bundle-linux-x86-20131030.zip
Official Website address http://developer.android.com/sdk/index.html
I don't understand what adt is.
Http://blog.csdn.net/aizquan/article/details/8974750
After that, extract the above two items to the virtual machine.
2. Set environment variables and add the following paths to PATH
Android-ndk-r9c
Adt-bundle-linux-x86-20131030/sdk/platform-tools
Adt-bundle-linux-x86-20131030/sdk/tools
3. Run gdbserver on the mobile phone (this step may be difficult to complete)
Push the gdbserver to your mobile phone. Start gdbserver with adb. Pay attention to the version number !!
130 | shell @ android:/$ gdbserver -- version
GNU gdbserver (GDB)
7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
Gdbserver is free software, covered by the GNU General Public License.
This gdbserver was configured as "arm-eabi-linux"
Shell @ android:/$ gdbserver 192.168.100.184: 1234/data/test
Process/data/test created; pid = 1877
Listening on port 1234
4. Execute
[Root @ localhost bin] # cd/home/randy/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin
[Root @ localhost bin] #./arm-linux-androideabi-gdb/Mnt/hgfs/CodeBlocks/TTS/arm-linux/test the red part is your executable file (cross-compiled)
GNU gdb (GDB)7.3.1-the version number of gg2 must be consistent with that of gdbserver.
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3 +: gnu gpl version 3 or later
This is free software: you are free to change and redistribute it.
There is no warranty, to the extent permitted by law. Type "show copying"
And "show warranty" for details.
This GDB was configured as "-- host = x86_64-linux-gnu -- target = arm-linux-android ".
For bug reporting instructions, please see:
...
Reading symbols from/mnt/hgfs/CodeBlocks/TTS/arm-linux/test... done.
(Gdb) shell adb forward tcp: 1234 tcp: 1234
(Gdb) target remote 127.0.0.1: 1234
Remote debugging using 127.0.0.1: 1234
0x00008120 in _ start ()
(Gdb) bt
#0 0x00008120 in _ start ()
(Gdb) B main. c: 42
Breakpoint 1 at 0x8290: file src/main. c, line 42.
(Gdb) c
Continuing.
Breakpoint 1, main (argc = 1, argv = 0xbefc1ad4) at src/main. c: 42
42 storePunctuationAndWord (cStringToExamine );
(Gdb)
Additional instructions on cross-compilation Command Options
[Root @ localhost TTS] # arm-linux-androideabi-gcc-g-o arm-linux/test src/main. c src/Table. c src/WordSegment. c src/TTS. c-L/usr/local/arm-linux/lib-static-l charset-l iconv-I/usr/local/arm-linux/include-I. /include
Arm-linux-androideabi-gcc cross compiler, under android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin
-G compiled executable files with debugging symbols
-O arm-linux/test: The final executable file is named test.
Src/main. c src/Table. c src/WordSegment. c src/TTS. c source files
-L/usr/local/arm-linux/lib-static-l charset-l iconv-I/usr/local/arm-linux/include-I. /include dependent dynamic library and header file path