Centos安装DDD调试器

12 篇文章 0 订阅

Centos版本为6.6,首先进这个网站下载最新版的DDD:  http://ftp.gnu.org/gnu/ddd/ 最新版的DDD竟然是09年更新的,现在都2015年了难过

解压后,进入目录:

  846  2015-05-11 10:56:06 cd ./下载/ddd-3.3.12
  847  2015-05-11 10:56:07 ls
  848  2015-05-11 10:56:12 ./configure 
然后就报错,报错主要原因是需要的相关的软件包没有安装上:

checking for tgetent in -lncurses... no
checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for termcap functions library... configure: error: No curses/termcap library found
缺少ncurses安装包:

  955  2015-05-10 14:12:37 yum install ncurses ncurses-devel

configure: error: The X11 library '-lX11' could not be found.
Please use the configure options '--x-includes=DIR'
and '--x-libraries=DIR' to specify the X location.
See the files 'config.log' and 'ddd/config.log'
for further diagnostics.
缺少openmotif:
  963  2015-05-10 16:41:26 yum install openmotif

checking for IceConnectionNumber in -lICE... no
checking whether libXext is in the standard X library path... yes
checking whether libXp is in the standard X library path... no
checking whether libXmu is in the standard X library path... no
checking for Motif... libraries (none), headers (none)
checking for Xpm... libraries in default path, headers in default path
checking for Athena... libraries in default path, headers (none)
checking whether compiling X headers requires -fpermissive... no
checking for XOpenDisplay in -lX11... yes
checking for _Xlcmbcurmax in -lXintl... no
checking for shmap in -lipc... no
checking for XtToolkitInitialize in -lXt... no
configure: error: The X toolkit library '-lXt' could not be found.
                  Please use the configure options '--x-includes=DIR'
                  and '--x-libraries=DIR' to specify the X location.
                  See the files 'config.log' and 'ddd/config.log'
                  for further diagnostics
缺少openmotif-devel:
  994  2015-05-11 10:52:03 yum install openmotif-devel
之后configure就成功了:



若还有别的错误,可以参考这个网站:http://blog.csdn.net/unix21/article/details/8450040

然后make,报错:


大概内容是:

strclass.C:1546: 错误:‘EOF’在此作用域中尚未声明
strclass.C:1559: 错误:‘EOF’在此作用域中尚未声明
strclass.C: In function ‘int readline(std::istream&, string&, char, int)’:
strclass.C:1589: 错误:‘EOF’在此作用域中尚未声明
strclass.C:1602: 错误:‘EOF’在此作用域中尚未声明
解决方法:

  850  2015-05-11 10:59:46 find -name strclass.C
  851  2015-05-11 11:00:01 vim ./ddd/strclass.c
找到路径后编辑在改文件头部加入 #define EOF -1

保存。
然后make成功!

  853  2015-05-11 11:01:07 make clean
  854  2015-05-11 11:01:25 make
  855  2015-05-11 11:05:31 sudo make install

然后随便编译一个C++程序:

[Jiakun@Kunge LeetCodeOJ]$ g++ -g -Wall -gstabs+ -o ./GrayCode GrayCode.cpp 
[Jiakun@Kunge LeetCodeOJ]$ ddd ./GrayCode &
[1] 9426

启动成功!

在DDD中显示行号:

Edit->Preferences->Source 选中Display Source Line Numbers

若使DDD运行时在xterm窗口中显示运行结果,则需安装xterm:

  999  2015-05-12 23:45:21 yum install xterm
然后在DDD中:

Program->Run in Execution Window就可以了




一些常见的g++编译选项和gdb命令:

g++ -g -Wall -gdwarf-2 -o ./GrayCode GrayCode.cpp
-g 选项让编译器将符号表(即对应于程序的变量和代码行的内存地址列表)保存在生成的可执行文件中,这样才能在调试会话过程中引用源代码中的变量名和行号。
-gstabs+作用:如果调试程序时,在gdb内p var,会提示No symbol "var" in current context.即使没有使用任何编译优化选项,可能是这些变量被优化到寄存器中,gdb无法读取。解决方案:在编译是加入 ‘-gstabs+’  选项
-gdwarf-2作用:当通过print命令打印查看程序中的变量值时,会发现总是出现值不正确的现象。这应该是gcc生成的调试信息与gdb版本不兼容造成的,加上-gdwarf-2。另-gdwarf-2与-gstabs+冲突
设置断点:    break 源代码行号
删除/清除断点:clear 行号
列出所有断点:info break
单步调试: next命令让gdb执行下一行,然后暂停。step命令的作用与此类似。只是在函数调用时step命令会进入函数,而next导致下一次暂停出现在调用函数之后。
恢复操作:continue命令通知调试器恢复执行,直到遇到新断点为止。
一次性断点:tbreak命令设置的断点在首次到达该指定行后就不再有效,只使用一次。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值