本次安裝分爲兩大部分:
解決依賴性和更改配置文件
一、解決依賴性
安裝
[root@vm4 ns2]# yum install gcc-c++ -y
問題1
make: *** [tk3d.o]
解決
[root@vm4 ns2]# yum install libX11-devel -y
問題2
can't find X includes
otcl-1.13 configuration failed! Exiting ...
解決
[root@vm4 ns2]# yum install libXt-devel -y
二、更改文件
問題3
解決
vim ns-2.33/tools/ranvar.cc,改爲如下
219 return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
問題4
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