本次安装分为两大部分:
解决依赖性和更改配置文件c++
1、解决依赖性
安装vim
[root@vm4 ns2]# yum install gcc-c++ -y
问题1bash
make: *** [tk3d.o]
解决app
[root@vm4 ns2]# yum install libX11-devel -y
问题2less
can't find X includes otcl-1.13 configuration failed! Exiting ...
解决dom
[root@vm4 ns2]# yum install libXt-devel -y
2、更改文件ide
问题3测试
解决this
vim ns-2.33/tools/ranvar.cc,改成以下 219 return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
问题4spa
make: *** [mac/mac-802_11Ext.o] Error 1
解决
vim ns-2.33/mac/mac-802_11Ext.h,添加 #include <cstddef>
问题5
make: *** [mobile/nakagami.o] Error 1
解决
vim ns-2.33/mobile/nakagami.cc 改成以下 183 resultPower = ErlangRandomVariable(Pr/m, int_m).value(); 185 resultPower = GammaRandomVariable(m, Pr/m).value();
问题6
linkstate/ls.h:137:58: note: declarations in dependent base ‘std::map<int, LsIdSeq, std::less<int>, std::allocator<std::pair<const int, LsIdSeq> > >’ are not found by unqualified lookup linkstate/ls.h:137:58: note: use ‘this->erase’ instead make: *** [linkstate/ls.o] Error 1
解决
vim ns-2.33/linkstate/ls.h 137 void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }
终于安装成功!!!!
快让我插会儿腰!!!!!
下面是根据提示信息配置环境变量
(/root/Desktop/ns2/ 是我安装的路径,你要把他改为你的路径)
vim ./bashrc PATH="$PATH:/root/Desktop/ns2/ns-allinone-2.33/bin:/root/Desktop/ns2/ns-allinone-2.33/tcl8.4.18/unix:/root/Desktop/ns2/ns-allinone-2.33/tk8.4.18/unix" LD_LIBRARY_PATH="/root/Desktop/ns2/ns-allinone-2.33/otcl-1.13:/root/Desktop/ns2/ns-allinone-2.33/lib" TCL_LIBRARY="$TCL_LIBRARY:/root/Desktop/ns2/ns-allinone-2.33/tcl8.4.18/library"
从新进入一个终端,发现ns出现%,nam 却有点问题
[root@vm4 ~]# ns % nam wrong # args: should be "namespace subcommand ?arg ...?" %
须要安装一下nam
[root@vm4 nam-1.13]# cd /root/Desktop/ns2/ns-allinone-2.33/nam-1.13 [root@vm4 nam-1.13]# ./configure [root@vm4 nam-1.13]# make 而后会发现出现了nam文件 [root@vm4 nam-1.13]# ls nam nam [root@vm4 nam-1.13]# cp nam ../bin
以后运行测试脚本,发现仍是有如下错误
[root@vm4 ex]# pwd /root/Desktop/ns2/ns-allinone-2.33/ns-2.33/tcl/ex [root@vm4 ex]# [root@vm4 ex]# ns simple.tcl [code omitted because of length] : no event type or button # or keysym while executing "bind Listbox <MouseWheel> { %W yview scroll [expr {- (%D / 120) * 4}] units }" invoked from within "if {[tk windowingsystem] eq "classic" || [tk windowingsystem] eq "aqua"} { bind Listbox <MouseWheel> { %W yview scroll [expr {- (%D)}] units } bind Li..."
解决方法
在配置文件的588行,以下添加(这是早期ns bug所致)
[root@vm4 generic]# vim /root/Desktop/ns2/ns-allinone-2.33/tk8.4.18/generitkBind.c 588 /* MappingNotify */ 0, 589 #ifdef GenericEvent 590 /* GenericEvent */ 0, 591 #endif 592 /* VirtualEvent */ VIRTUAL, 以后再从新编译和拷贝新的二进制。 [root@vm4 ns-allinone-2.33]# ./install [root@vm4 nam-1.13]# cp nam ../bin
激动人心,nam终于好了!!!
最后安装xgraph
[root@vm4 xgraph-12.1]#cd /root/Desktop/ns2/ns-allinone-2.33/xgraph-12.1 [root@vm4 xgraph-12.1]# ./configure [root@vm4 xgraph-12.1]# make
出现错误
dialog.c:780:5: error: too few arguments to function ‘getline’ dialog.c:891:1: error: conflicting types for ‘getline’
解决:根据提示将780和891中getline改成newgetline
vim dialog.c 780 while (newgetline(&lineptr, line)) 891 newgetline(tptr, lptr)
以后再来一遍编译三部曲。
啊!!! 撒花啊撒花
最后的最后,finally