Porting the ncurses library
The ncurses version used in this article is ncurses-5.9.tar.gz
Download address: https://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
1. Copy the ncurses compressed package to the Linux host or use the wget command to download and decompress it
tar-zxvfncurses-5.9.tar.gz
2. After decompression, enter the ncurses-5.9 directory
cdncurses-5.9
3. Create the generated file location after compilation in the ncurses-5.9 directory
mkdiroutput
cdoutput
mkdirarm-linux
4. Generate Makefile
./configure--target=arm-none-linux-gnueabi--prefix=$PWD/output/arm-linux--enable-termcap--with-shared--without-ada
- --target indicates the compiler prefix, which needs to be modified according to different compilation requirements
- --prefix indicates the location of the generated file after compilation
- --nable-termcap means key codes use the termcap (terminalcapabilities) database [autodetect]
- --with-shared means dynamic compilation
5. Compile
make
When you encounter the following error
Makefile:794:recipefortarget'../obj_s/lib_gen.o'failed
make[1]:***[../obj_s/lib_gen.o]Error1
make[1]:Leavingdirectory'.../ncurses-5.9/ncurses'
Makefile:109:recipefortarget'all'failed
make:***[all]Error2
You need to go to the ncurses-5.9/include folder, modify the following content in the curses.tail file, and remove the comment /* generated */
externNCURSES_EXPORT(bool)mouse_trafo(int*,int*,bool);/*generated*/
6. Installation
Makeinstall
7. After the installation is complete, the library file will be generated in the /output/arm-linux directory. We only need to copy the libncurses.so.5 library in the lib directory to the development board
Porting gdb
The gdb version used in this article is gdb-7.12.tar.gz
Download address: https://ftp.gnu.org/gnu/gdb/gdb-7.12.tar.gz
1. Copy the gdb compressed package to the Linux host or use the wget command to download and decompress it
tar-zxvfgdb-7.12.tar.gz
2. After decompression, enter the ncurses-5.9 directory
cdgdb-7.12
3. Generate Makefile
./configure-host=arm-none-linux-gnueabiCC=/home/vanxoak/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc--enable-shared--prefix=$PWD/output/arm-linux--disable-werror--without-x--disable-gdbtk--disable-tui--without-included-regex--without-included-gettextLDFLAGS="-L$PWD/../output/arm-linux/lib"CPPFLASS="-I$PWD/../output/arm-linux/include"
- --host=arm-none-linux-gnueabi Compile with arm-none-linux-gnueabi
- CC is the absolute path of the cross compiler
- --enable-shared dynamic compilation
- prefix="$PWD/output/arm-linux" installation directory
- --disable-werror disable werror alarm
- --without-x disable x windows support
- --disable-gdbtk disable gdbtk
- --disable-tui disable tui interface
- --without-included-gettext removes the gettext library for multi-language processing
- "LDFLAGS=XXX" refers to the path of the cross-compiled ncurse lib directory
- "CPPFLAGS=XXX" refers to the include directory path of the cross-compiled ncurse
4. Compile
make
5. Installation
makeinstall
After the installation is complete, the gdb executable program will be generated in the .../gdb-7.12/output/arm-linux/bin/ directory.
Ported to HDT3-EVM development board
1. Copy the libncurses.so.5 library file to the /usr/lib directory. If there is no lib directory in the /usr directory, you can manually create it with mkdir lib
2. Copy the gdb program to the /bin directory
EEWORLDIMGTK1
Test and Debug
1. Write an executable test program. The sample hello.c code is as follows. After the code is executed, Hello World will be printed.
#include<stdio.h>
intmain(intargc,char*argv[])
{
printf("HelloWorld\n");
return0;
}
2. Use the cross compiler to compile. It should be noted that to use gdb to debug the program, you need to add the "-g" parameter to retain the debugging information when compiling the source code with the cross compiler. Otherwise, you cannot use GDB for debugging and report the error shown in the last line below:
/home#gdbhello
GNUgdb(GDB)7.12
Copyright(C)2016FreeSoftwareFoundation,Inc.
LicenseGPLv3+:GNUGPLversion3orlater<http://gnu.org/licenses/gpl.html>
Thisisfreesoftware:youarefreetochangeandredistributeit.
ThereisNOWARRANTY,totheextentpermittedbylaw.Type"showcopying"
and"showwarranty"fordetails.
ThisGDBwasconfiguredas"arm-none-linux-gnueabi".
Type"showconfiguration"forconfigurationdetails.
Forbugreportinginstructions,pleasesee:
<http://www.gnu.org/software/gdb/bugs/>.
FindtheGDBmanualandotherdocumentationresourcesonlineat:
<http://www.gnu.org/software/gdb/documentation/>.
Forhelp,type"help".
Type"aproposword"tosearchforcommandsrelatedto"word"...
Readingsymbolsfromhello...(nodebuggingsymbolsfound)...done.
3. Compile the test program using the cross compiler
arm-none-linux-gnueabi-gcc-g-ohellohello.c
4. Copy the generated hello file to the HDT3-EVM development board and save it using the sync command
5. Enter the gbd command to start the gdb program
/home#gdb
GNUgdb(GDB)7.12
Copyright(C)2016FreeSoftwareFoundation,Inc.
LicenseGPLv3+:GNUGPLversion3orlater<http://gnu.org/licenses/gpl.html>
Thisisfreesoftware:youarefreetochangeandredistributeit.
ThereisNOWARRANTY,totheextentpermittedbylaw.Type"showcopying"
and"showwarranty"fordetails.
ThisGDBwasconfiguredas"arm-none-linux-gnueabi".
Type"showconfiguration"forconfigurationdetails.
Forbugreportinginstructions,pleasesee:
<http://www.gnu.org/software/gdb/bugs/>.
FindtheGDBmanualandotherdocumentationresourcesonlineat:
<http://www.gnu.org/software/gdb/documentation/>.
Forhelp,type"help".
Type"aproposword"tosearchforcommandsrelatedto"word".
(gdb)
The above code (gdb) is the internal command guide of GBD, which means waiting for the user to enter the gbd command
6. Use the " file hello " command to load the test program being debugged
(gdb)filehello
Readingsymbolsfromhello...done.
Displays Reading symbols from hello...done. This indicates that the program under test has been loaded successfully.
7. Use the "r" command to execute the debug test program
(gdb)r
Startingprogram:/home/hello
HelloWorld
[Inferior1(process849)exitednormally]
If the above code displays "Hello World", it means that the hello program has been executed.
(gdb)help
Listofclassesofcommands:
aliases--Aliasesofothercommands
breakpoints--Makingprogramstopatcertainpoints
data--Examiningdata
files--Specifyingandexaminingfiles
internals--Maintenancecommands
obscure--Obscurefeatures
running--Runningtheprogram
stack--Examiningthestack
status--Statusinquiries
support--Supportfacilities
tracepoints--Tracingofprogramexecutionwithoutstoppingtheprogram
user-defined--User-definedcommands
Type"help"followedbyaclassnameforalistofcommandsinthatclass.
Type"helpall"forthelistofallcommands.
Type"help"followedbycommandnameforfulldocumentation.
Type"aproposword"tosearchforcommandsrelatedto"word".
Commandnameabbreviationsareallowedifunambiguous.