原文地址:ubuntu下ns2-allinone-2.34安装方法【呕心沥血整理版】作者:寒枫傲天
最近一直在使用ns2,遇到各种问题,需要各种重装,特此整理一下安装过程。
首先下载到ns-allinone-2.34.tar.gz,这个网上到处都是。
然后开始在终端里输入命令,获取ns2需要的相关软件:
sudo apt-get install build-essential
sudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev
sudo apt-get install libxmu-dev libxmu-headers
sudo apt-get install xorg-dev g++ xgraph

sudo apt-get install g++-4.4
===============================

然后解压ns-allinone-2.34.tar.gz,放到你指定的目录。
检查你的gcc版本,如果gcc版本大于4.0(大部分人的都是,建议直接改),要在执行./install之前作出一些修改。
gcc4.0版本以前是用ld-share来生成共享库的,但是到了4.0以上的版本,这个命令改为了gcc-share。
修改命令如下:
cdns-allinone-2.34/otcl-1.13
  
  sudogedit configure.in
  把77行处的
  SHLIB_LD="ld-shared"
  改为
  SHLIB_LD="gcc-shared"
  保存退出,然后
  
  sudogedit configure
  把6304行(Ctrl+i跳到6304行)的
  SHLIB_LD="ld-shared"
  改为
  SHLIB_LD="gcc-shared"
  保存退出,然后
  cdns-allinone-2.34 #到安装目录
  sudo./install #开始安装
如果没有更改直接安装,就会出现这样的错误:
ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined
ld: final link failed: Bad value
make: *** [libotcl.so] Error 1
这只是有可能出现的第一个错误,接下来还有更多的错误等着你!(所以要整理出这么一份东西来。。。)
=======================================================================================
错误一:安装NS2.34过程中出现如下的错误:
tools/ranvar.cc: In member function ‘virtual double GammaRandomVariable::value()’:
tools/ranvar.cc:219:70: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly
tools/ranvar.cc:219:70: error:  for a function-style cast, remove the redundant ‘::GammaRandomVariable’
make: *** [tools/ranvar.o]错误1
Ns make failed!
See http://www.isi.edu/nsnam/ns/ns-problems.html for problems

这是由于gcc版本提高后对类内部函数调用的简化造成的不兼容,解决方法如下:

在ns-allinone-2.34/ ns-2.34/tools文件夹下,找到报错提示中的ranvar.cc文件,打开找到对应的219行删除::GaammaRandomVariable,保存,

即:将219行的

return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);

改为:

return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);

然后保存退出,重新安装ns2.

======================================================================================

错误二:

In file included from mac/mac-802_11Ext.cc:66:0:

mac/mac-802_11Ext.h: In member function ‘u_int32_t PHY_MIBExt::getHdrLen11()’:

mac/mac-802_11Ext.h:175:19: error: expected primary-expression before ‘struct’

mac/mac-802_11Ext.h:175:41: error: ‘dh_body’ was not declared in this scope

mac/mac-802_11Ext.h:175:51: error: ‘offsetof’ was not declared in this scope

mac/mac-802_11Ext.h:177:3: warning: control reaches end of non-void function [-Wreturn-type]

make: *** [mac/mac-802_11Ext.o] Error 1

Ns make failed!

下面是网上找得关于本问题的解决方案:

If you get error like:

mac/mac-802_11Ext.h: In member function ‘u_int32_t PHY_MIBExt::getHdrLen11()’:
mac/mac-802_11Ext.h:176:19: error: expected primary-expression before ‘struct’
mac/mac-802_11Ext.h:176:41: error: ‘dh_body’ was not declared in this scope
mac/mac-802_11Ext.h:176:51: error: ‘offsetof’ was not declared in this scope

open that file and add

#include <cstddef>

to the header files.
在ns-allinone-2.34ns-2.34macmac-802_11Ext.h 文件添加#include <cstddef>
然后重新安装,就OK了。

=============================================================================

错误三:

mobile/nakagami.cc: In member function ‘virtual double Nakagami::Pr(PacketStamp*, PacketStamp*, WirelessPhy*)’:

mobile/nakagami.cc:183:73: error: cannot call constructor ‘ErlangRandomVariable::ErlangRandomVariable’ directly

mobile/nakagami.cc:183:73: error:  for a function-style cast, remove the redundant ‘::ErlangRandomVariable’

mobile/nakagami.cc:185:67: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly

mobile/nakagami.cc:185:67: error:  for a function-style cast, remove the redundant ‘::GammaRandomVariable’

make: *** [mobile/nakagami.o]错误1

Ns make failed!

See http://www.isi.edu/nsnam/ns/ns-problems.html for problems

解决方法:

在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的nakagami.cc文件,打开找到对应的183行删除::ErlangRandomVariable,保存,

即:将183行的

resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();

改为:

resultPower = ErlangRandomVariable(Pr/m, int_m).value();

在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的nakagami.cc文件,打开找到对应的185行删除::GammaRandomVariable,保存,

即:将185行的

resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();

改为:

resultPower = GammaRandomVariable(m, Pr/m).value();

重新在ns目录下键入$ ./install安装,再次出现同类问题时,仿照此次解决方法,找到对应的文件和行数,修改即可。直到安装成功。

=======================================================================================

到这里安装终于成功了,不要忘记添加环境变量
在/home目录下
sudo gedit .bashrc在弹出的窗口文件最后输入export PATH=$PATH:/home/yourfile/ns-allinone-2.34/bin:/home/yourfile/ns-allinone-2.34/tcl8.4.18/unix:/home/yourfile/ns-allinone-2.34/tk8.4.18/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/yourfile/ns-allinone-2.34/otcl-1.13:/home/yourfile/ns-allinone-2.34/lib

export TCL_LIBRARY=$TCL_LIBRARY:/home/yourfile/ns-alllinone-2.34/tcl8.4.18/library

============================

验证(测试)
   (1)打开一个新的终端
   (2)输入ns并回车
   $ns (如果正常,会出现"%"操作提示符,如果显示还没有安装ns2,可以先安装nam,再测试ns)
   (3)输入一段测试用的Tcl脚本代码进行测试
   %puts "Hello World" (输出Hello World字符串)
   Hello World (如果正确,会显示Hello World)
   % (然后跳到下一个"%"提示符等待下一条指令输入)

============================
安装nam
   cd ns-allinone-2.34/nam-1.14
   ./configure
   make
   sudo make install (至此,nam安装好)

在终端中输入nam命令,弹出nam界面则说明nam安装好了

到此ns2终于安装好!!

如果遇到其他安装过程中的问题还会继续更新本文。

PS: ns2相关学习资料网址

百思论坛

http://www.baisi.net/forum-440-1.html

向ns2中添加新的队列算法

http://www.cs.cmu.edu/~istoica/csfq/step-by-step.html#fred-ref

ns2教学手册

http://hpds.ee.ncku.edu.tw/~smallko/ns2/ns2.htm

ubuntu下ns2-allinone-2.34…相关推荐

  1. ubuntu下firefox中,直接在网页上安装程序的方法

    我不知道别人是怎么做的,反正这个问题恶心死了. ubuntu下安装软件,一般都是gogole到一个页面,然后上面告诉你把下面的代码输入到ternimal. sudo apt-add-repositor ...

  2. ubuntu下终端提示符设置

    PS1变量 修改/ect下bash.bashrc文件PS1变量 \d :代表日期,格式为weekday month date,例如:"Mon Aug 1" \H :完整的主机名称. ...

  3. ubuntu下c++中base64编解码测试和图片编解码测试

    全栈工程师开发手册 (作者:栾鹏) 架构系列文章 字符数组的base64编解码 base64.h #include <string>std::string base64_encode(un ...

  4. ubuntu下rsync两个服务器同步文件

    前言 文件服务器为ubuntu的,客户端为windows的环境 主服务器配置 在Ubuntu下安装rsync通过以步骤可以实现: sudo apt-get install rsync xinetd 编 ...

  5. Ubuntu下源码编译VirtualBox六 —— 源码编译(5)

    接前一篇文章<Ubuntu下源码编译VirtualBox五 -- 源码编译(4)>,链接如下: Ubuntu下源码编译VirtualBox五 -- 源码编译(4)_蓝天居士的博客-CSDN ...

  6. Windows和ubuntu下一些提升效率的工具知识点以及typora和Obsidian配置

    文章目录 一.软件 windows ubuntu 二.软件知识点 三.Google chrome好用的插件 四.自己安装的Obisidian插件 五.Typora和Obsidian图片显示兼容问题 六 ...

  7. 去掉ubuntu下windows文件夹绿色背景

    在ubuntu下打开Windows文件夹,有绿色背景.原因是那些文件夹的读写执行访问权限引起的.在 Ubuntu中,不同权限的文件/文件夹 有不同的颜色.本文先讲方法,方法很简单,两步就完成.有兴趣的 ...

  8. ubuntu下修改终端字体颜色以及terminator字体美化

    Ubuntu下终端字体如果全是白色很不直观,可以根据自己喜好修改颜色. 2019年快乐,ros indigo很快就要停止维护了,昨天把ubuntu重装成16.04,装了ros kinetic,以前配好 ...

  9. anaconda环境---ubuntu下重装

    anaconda环境---ubuntu下重装 @wp20190312 为何重装? 配置一个环境,意外发现conda命令不好用了,提示"找不到conda模块",整个conda虚拟环境 ...

最新文章

  1. fancybox关闭弹出窗体parent.$.fancybox.close();
  2. verilog 8位流水灯_用单片机控制的LED流水灯设计
  3. 漫步数理统计十七——条件分布与期望
  4. Normal Map Compress with DXT5
  5. 惊,Java 字符串拼接竟然有这么多玩法!| CSDN 原力计划
  6. Leetcode 561.数组拆分I
  7. 我的CSDN原创高质量免积分下载资源列表
  8. python 12306登录_Python Selenium自动登录12306官网
  9. linux下 Wowza安装与ffmpeg测试
  10. 计算机模拟仿真技术的功能,浅谈虚拟仿真技术
  11. @JsonFormat和@DataFormat的使用
  12. MASM 32位汇编 32与16汇编区别
  13. Python文本处理(3)——文本表示之 one-hot 词向量(1)——纯小白都能懂!
  14. unity ToggleGroup和Toggle.isOn的坑
  15. Java final String类的详细用法还有特性说明,自己也在学习.
  16. 设计模式之--策略模式
  17. 变分(Calculus of variations)的概念及运算规则(二)
  18. ios在判断设备是ipad_识别您的 iPad 机型
  19. 案例十、检测域名是否到期
  20. 2D横板动作游戏常用角色移动逻辑(转)

热门文章

  1. 零基础小白复现Java 若依项目
  2. ios::sync_with_stdio(false)
  3. 关于Android Studio 中Android SDK的 SDK Tools 没有CMake下载项问题
  4. 使用openssl的EVP接口使用sm2算法加解密等操作
  5. 用百度访问受限的MSN space空间
  6. react-native : 开发工具转帖记录
  7. 数据建模java_数据建模及常见分类算法
  8. ADS设计日志(一):阻抗变换器详讲
  9. 2021年全国职业技能大赛:网络系统管理项目
  10. ubuntu 22.04 安装 curl 的方法