红联Linux门户
Linux帮助

在ubuntu14.04中安装和配置NS-2

发布时间:2015-09-08 22:16:31来源:linux网站作者:lvniu321

1、更新系统:在终端输入如下命令

sudo app-get update #更新源列表
sudo app-get upgrade #更新已经安装的包
sudo app-get dist-upgrade #更新软件,升级系统


2、安装几个需要的包

sudo apt-get install build-essential
sudo apt-get install tcl8.5 tcl8.5-dev tk8.5 tk8.5-dev #for tcl and tk
sudo apt-get install libxmu-dev libxmu-headers #for nam


3、下载安装包,并复制到需要安装的目录,在这里需要取得root权限才可以安装

官网下载地址:http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download,这里下载allinone

tar xvfz ns-allinone-2.35.tar.gz
cd ns-allinone-2.35

./install #进行安装

安装过程中出现错误:

In file included from linkstate/ls.cc:67:0:
linkstate/ls.h: In instantiation of ‘void LsMap::eraseAll() [with Key = int; T = LsIdSeq]’:
linkstate/ls.cc:396:28: required from here
linkstate/ls.h:137:20: error: ‘erase’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
linkstate/ls.h:137:20: note: declarations in dependent base ‘std::map, std::allocator > >’ are not found by unqualified lookup
linkstate/ls.h:137:20: note: use ‘this->erase’ instead
make: *** [linkstate/ls.o] Error 1
Ns make failed!

解决方法:
将 ns/ns-2.35/linkstate/ls.h中的137行void eraseAll() { erase(baseMap::begin(), baseMap::end()); }改为 void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }
然后重新执行 sudo ./install


4、配置环境变量

在当前用户目录下,编辑.bashrc文件

sudo vim .bashrc

在文件末尾添加

# add path for ns2
export PATH="$PATH:/home/liushun/ns-allinone-2.35/bin:/home/安装文件夹名/ns-allinone-2.35/tcl8.5.10/unix:/home/安装文件夹名/ns-allinone-2.35/tk8.5.10/unix"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/安装文件夹名/ns-allinone-2.35/otcl-1.14:/home/安装文件夹名/ns-allinone-2.35/lib"
export TCL_LIBRARY="$TCL_LIBRARY:/home/安装文件夹名/ns-allinone-2.35/tcl8.5.10/library"


5、验证安装

进入控制台,输入ns,这时会提示安装ns2,根据提示输入

sudo apt-get install ns2

再次输入ns,出现%,说明安装成功

输入nam,报错,这时提示安装nam,根据提示输入

sudo apt-get install nam

如果以上命令失效,可先输入

sudo apt-get update #进行更新


在Ubuntu 11.04中安装ns-2.33出现的错误及其解决方法:http://www.linuxdiyf.com/linux/6949.html