ubuntu14.3下安装ns2.35安装详解

来源:互联网 发布:黄金价格数据 编辑:程序博客网 时间:2024/06/06 23:12

收集整理以及自己在安装过程中的一些问题:

Step1: 更新系统。在终端输入如下命令  

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

网上有很多都是让先进行系统更新,但其实是不用的,更新系统太浪费时间,所以免去第一步直接进行第二步

Step2:安装几个需要的包

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

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

下载软件:NS2.35软件ns-allinone-2.35.tar.gz下载地址:http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download

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!

解决方案

修改ls文件:ns-2.35/linkstate/ls.h

第137行

void eraseAll() { erase(baseMap::begin(), baseMap::end()); }

改为:void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }

然后重新 ./install,在经过一段时间后,终于有如下提示:


安装成功

Step4:配置环境变量

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

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"


Step5:验证安装

测试NS2,在终端输入#ns 则出现% 说明安装成功
然后运行
#ns   /root/桌面/ns-allinone-2.35/ns-2.35/tcl/ex/simple.tcl 
出现窗口如下即可

可能遇到的一些问题解决方案:

1.make: *** [tk3d.o] 错误 1

tk8.5.10 make failed! Exiting ...

安装libx11-dev可以解决问题

sudo apt-get install libx11-dev


2.can't find X includes
otcl-1.14 configuration failed! Exiting ...

安装libXt-dev可以解决问题

sudo apt-get install libXt-dev


3.make: g++:命令未找到
make: *** [tcl2c++] 错误 127
tclcl-1.20 make failed! Exiting ...

先输入g++看g++有没有被安装,原来我的g++还没安装好如果没由安装好则

sudo apt-get install g++


最后安装好设置环境变量  在/home/user下编辑 .bashrc 

export NS_HOME=/home/chenkai/ns/ns-allinone-2.35
export PATH=$NS_HOME/nam-1.15:$NS_HOME/tcl8.5.10/unix:$NS_HOME/tk8.5.10/unix:$NS_HOME/bin:$PATH
export LD_LIBRARY_PATH=$NS_HOME/tcl8.5.10/unix:$NS_HOME/tk8.5.10/unix:$NS_HOME/otcl-1.14:$NS_HOME/lib:$LD_LIBRARY_PATH
export TCL_LIBRARY=$NS_HOME/tcl8.5.10/library

输入source .bashrc  使环境变量有效。


最后验证ns。

在控制台输入ns 

%

显示安装成功。

解决nam问题:

出现Can't find a usable TK.tcl in the following directories .......

只要在环境变量中加入

export TCL_LIBRARY=/usr/local/lib/tcl8.10/library
     export  TK_LIBRARY=/usr/local/lib/tk8.10/library

以上还有一点要注意:

如果我们添加了以上的TCL_LIBRARY以及TK_LIBRARY后仍然有问题,那么要去设置成一下这样:

TCL_LIBRARY=/usr/local/lib/tcl8.10/library:/usr/local/lib/tk8.10/library

还要查看在用户目录下配置的.bashrc和root目录下配置的bash.bashrc(ubuntu下)是否重复或覆盖

参考网址:http://blog.sina.com.cn/s/blog_6de000c20101lomm.html

参考网址:http://blog.csdn.net/chenkai619/article/category/1084323


0 0
原创粉丝点击