
移植ncurses庫(kù)
本文使用的ncurses版本為ncurses-5.9.tar.gz
1. 將ncurses壓縮包拷貝至Linux主機(jī)或使用wget命令下載并解壓
tar-zxvfncurses-5.9.tar.gz
2. 解壓后進(jìn)入到ncurses-5.9目錄下
cdncurses-5.9
3. 在ncurses-5.9目錄下創(chuàng)建編譯完成后生成文件位置
mkdiroutput
cdoutput
mkdirarm-linux
4. 生成Makefile文件
./configure--target=arm-none-linux-gnueabi--prefix=$PWD/output/arm-linux--enable-termcap--with-shared--without-ada
- --target表示編譯器的前綴,需要根據(jù)編譯的不同需求進(jìn)行修改
- --prefix表示編譯完成后生成文件的位置
- --nable-termcap表示關(guān)鍵代碼使用termcap(terminalcapabilities)數(shù)據(jù)庫(kù)[自動(dòng)檢測(cè)]
- --with-shared表示動(dòng)態(tài)編譯
5. 編譯
make
當(dāng)遇到如下報(bào)錯(cuò)時(shí)
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
需要進(jìn)入ncurses-5.9/include文件夾,修改curses.tail文件下的如下內(nèi)容,將注釋/*generated*/去掉
externNCURSES_EXPORT(bool)mouse_trafo(int*,int*,bool);/*generated*/
6. 安裝
Makeinstall
7. 安裝完成后會(huì)在/output/arm-linux目錄下生成庫(kù)文件,我們只需將lib目錄下的libncurses.so.5庫(kù)拷貝至開發(fā)板
移植gdb
本文使用的gdb版本為gdb-7.12.tar.gz
1. 將gdb壓縮包拷貝至Linux主機(jī)或使用wget命令下載并解壓
tar-zxvfgdb-7.12.tar.gz
2. 解壓后進(jìn)入到ncurses-5.9目錄下
cdgdb-7.12
3. 生成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用arm-none-linux-gnueabi編譯
- CC為交叉編譯器絕對(duì)路徑
- --enable-shared動(dòng)態(tài)編譯
- prefix=“$PWD/output/arm-linux”安裝目錄
- --disable-werror屏蔽werror報(bào)警
- --without-x取消xwindows支持
- --disable-gdbtk取消gdbtk
- --disable-tui取消tui界面
- --without-included-gettext去掉用于多語(yǔ)言處理的gettext庫(kù)
- "LDFLAGS=XXX"指交叉編譯完成的ncurse的lib目錄路徑
- "CPPFLAGS=XXX"指是交叉編譯完成的ncurse的include目錄路徑
4. 編譯
make
5. 安裝
makeinstall
安裝完成后會(huì)在.../gdb-7.12/output/arm-linux/bin/目錄下生成gdb可執(zhí)行程序。
移植至HDT3-EVM開發(fā)板
1. 將libncurses.so.5庫(kù)文件拷貝至/usr/lib目錄下,若/usr目錄下無(wú)lib目錄可手動(dòng)創(chuàng)建mkdirlib
2. 將gdb程序拷貝至/bin目錄下

?
測(cè)試調(diào)試
1. 編寫可執(zhí)行測(cè)試程序,示例hello.c代碼如下,該代碼執(zhí)行后會(huì)打印HelloWorld。
#include
intmain(intargc,char*argv[])
{
printf("HelloWorld\n");
return0;
}
2. 使用交叉編譯器進(jìn)行編譯,需要注意的是,要使用gdb調(diào)試程序,需要在使用交叉編譯器編譯源代碼時(shí)加上"-g"參數(shù)保留調(diào)試信息,否則不能使用GDB進(jìn)行調(diào)試且報(bào)如下最后一行所示錯(cuò)誤:
/home#gdbhello
GNUgdb(GDB)7.12
Copyright(C)2016FreeSoftwareFoundation,Inc.
LicenseGPLv3+:GNUGPLversion3orlater
Thisisfreesoftware:youarefreetochangeandredistributeit.
ThereisNOWARRANTY,totheextentpermittedbylaw.Type"showcopying"
and"showwarranty"fordetails.
ThisGDBwasconfiguredas"arm-none-linux-gnueabi".
Type"showconfiguration"forconfigurationdetails.
Forbugreportinginstructions,pleasesee:
.
FindtheGDBmanualandotherdocumentationresourcesonlineat:
.
Forhelp,type"help".
Type"aproposword"tosearchforcommandsrelatedto"word"...
Readingsymbolsfromhello...(nodebuggingsymbolsfound)...done.
3. 使用交叉編譯器編譯測(cè)試程序
arm-none-linux-gnueabi-gcc-g-ohellohello.c
4. 將生成的hello文件拷貝至HDT3-EVM開發(fā)板上并使用sync命令保存
5. 輸入gbd命令啟動(dòng)gdb程序
/home#gdb
GNUgdb(GDB)7.12
Copyright(C)2016FreeSoftwareFoundation,Inc.
LicenseGPLv3+:GNUGPLversion3orlater
Thisisfreesoftware:youarefreetochangeandredistributeit.
ThereisNOWARRANTY,totheextentpermittedbylaw.Type"showcopying"
and"showwarranty"fordetails.
ThisGDBwasconfiguredas"arm-none-linux-gnueabi".
Type"showconfiguration"forconfigurationdetails.
Forbugreportinginstructions,pleasesee:
.
FindtheGDBmanualandotherdocumentationresourcesonlineat:
.
Forhelp,type"help".
Type"aproposword"tosearchforcommandsrelatedto"word".
(gdb)
上述代碼(gdb)為GBD內(nèi)部命令引導(dǎo)符,表示等待用戶輸入gbd命令
6. 使用"filehello"命令載入被調(diào)試的測(cè)試程序
(gdb)filehello
Readingsymbolsfromhello...done.
顯示Readingsymbolsfromhello...done.表示被測(cè)程序加載成功
7. 使用"r"命令執(zhí)行調(diào)試測(cè)試程序
(gdb)r
Startingprogram:/home/hello
HelloWorld
[Inferior1(process849)exitednormally]
如上述代碼顯示"HelloWorld"即表示hello程序執(zhí)行完成
(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.
-
Linux
+關(guān)注
關(guān)注
88文章
11760瀏覽量
219036 -
編譯器
+關(guān)注
關(guān)注
1文章
1672瀏覽量
51611 -
全志
+關(guān)注
關(guān)注
25文章
311瀏覽量
54738
發(fā)布評(píng)論請(qǐng)先 登錄
使用GDB調(diào)試Linux應(yīng)用程序
ARM-Linux與MCU開發(fā)的不同之處
基于ARM-Linux的MiniGUI的仿真與移植
ARM-Linux指紋識(shí)別系統(tǒng)的設(shè)計(jì)
嵌入式Linux的GDB調(diào)試環(huán)境建立
嵌入式Linux系統(tǒng)的GDB遠(yuǎn)程調(diào)試的實(shí)現(xiàn)
ARM-Linux開發(fā)與MCU開發(fā)有何不同?上篇
ARM-Linux開發(fā)與MCU開發(fā)比較
ARM-Linux開發(fā)與MCU開發(fā)的各自優(yōu)勢(shì)?
ARM-Linux開發(fā)和MCU開發(fā)的不同點(diǎn)
基于ARM-Linux指紋識(shí)別系統(tǒng)的設(shè)計(jì)
gdb本地調(diào)試版本移植至ARM-Linux系統(tǒng)
評(píng)論