最准的五路财神招财咒:NS2:建树Eclipse景象,及往Eclipse中添加Debug模式碰到的题目解决

来源:百度文库 编辑:中财网 时间:2024/05/09 15:41:53

前提是,按照此篇博文中的办法

http://blog.karthiksankar.com/ns2-eclipse/

安装好ns-2.34并开启eclipse的workspace.

中心可能碰到的题目如下,解决办法是一样的。

1. 若是选择create a new Makefile project existing code的话,点击finish,eclipse没有任何反响。此处原因不详。

2. 若是遵守此博文,选择C++project下面的Makefile project->Empty Project的话,eclipse报错如下:

/ns-2.34 overlaps location of another project:""ns-2.34""。

这是因为在此folder里面已经有了ns-2.34 的所有source code,所以你新建树的ns-2.34的project和此文件夹重名了。

 

上述两题目解决办法:依然选择File->New->C++ Project. Project type里面选择Makefile project->Empty Project.

Project name填ns-2.34, 将Use default location的勾去掉,选择你ns2的默认安装路径,比如/home/xxx/ns-allinone-2.34/ns-2.34,此时呈现错误2.

这时资料经管器或者terminal 进入到/home/xxx/ns-allinone-2.34/ns-2.34, 将ns-2.34 全部文件夹剪切出来,错误消散。

此时点击next,finish。

打开workspace今后,将剪切出来的文件夹从头粘贴到/home/xxx/ns-allinone-2.34/ 文件夹下,与此目次下的ns-2.34文件夹归并。

OK,如今的eclipse for ns2已经可以应用了。

 

二:往Eclipse添加NS2的debug模式

前提是,依然遵守上述博文做如下更改。

Changes to be made in Makefile.in file:

Add -g to the line CCOPT = @V_CCOPT@

CCOPT = @V_CCOPT@ -g

Add -DNDEBUG -DDEBUG to the end of the following line:

DEFINE = -DTCP_DELAY_BIND_ALL -DNO_TK @V_DEFINE@ @V_DEFINES@ @DEFS@-DNS_DIFFUSION -DSMAC_NO_SYNC 
-DCPP_NAMESPACE=@CPP_NAMESPACE@-DUSE_SINGLE_ADDRESS_SPACE -Drng_test -DNDEBUG -DDEBUG

 

更改后若应用 ./configure --enable-debug号令并make clean,make今后,会呈现如下错误:

In file included tcp/tcp-linux.cc:47:
tcp/tcp-linux.h:64:1: error: "DEBUG" redefined
: error: this is the location of the previous definition
make: *** [tcp/tcp-linux.o] Error 1

原因是:上方添加的—DDEBUG与NS2自身所携带的DEBUG模式不克不及兼容,此为wikipedia给出的申明,今朝ns小组正在进行debug解决此题目。

 

那么本人的选择是放弃ns2自身所带debug对象而应用DDEBUG,那么只须要从头./configure并make clean,make 即可。

此时依然会呈现错误提示,一般格局如下:

mobile/shadowing-vis.cc: In member function ‘int ShadowingVis::getPropCond(float, float, float, float)’:
mobile/shadowing-vis.cc:294: error: ‘xx’ was not declared in this scope
mobile/shadowing-vis.cc:294: error: ‘yy’ was not declared in this scope
make: *** [mobile/shadowing-vis.o] Error 1

解决办法:将含有此项目组的代码注释掉,比如上述错误可以将这段代码注释掉:

/*
#ifdef DEBUG
   printf("xx = %f  yy = %f", xx, yy);
   printf("pixel = %x", pixel[xIdx + yIdx * width]);
#endif

*/

提示:因为此时Eclipse已经可以debug了--依然是按照上述博文将debug选项设置完毕-- 所以,可以应用Eclipse对NS2进行编译,build之后就会呈现上述错误提示,双击错误提示打开响应文档,找到上述代码,注释掉即可。

此类错误大约有3-4处,记不太清了,全部注释掉就可以了。

 

如今,NS2就可以正常工作了,理论上来讲,也可以debug了,然则笔者正在码代码,还没开端debug,所以对其debug是否有效不得而知。