linux下Ns2安装

1.下载ns-allinone-2.33.tar.gz

2. 解压 进入ns-allinone-2.33目录

3. 运行./install命令

4.出现错误


一、
ld -shared-o libotcl.so otcl.o
otcl.o: Infunction `OTclDispatch':
/usr/ns-allinone-2.34/otcl-1.13/otcl.c:495:undefined reference to `__stack_chk_fail_local'
otcl.o: Infunction `Otcl_Init':
/usr/ns-allinone-2.34/otcl-1.13/otcl.c:2284:undefined reference to `__stack_chk_fail_local'
ld:libotcl.so: hidden symbol `__stack_chk_fail_local' isn'tdefined
ld: finallink failed: Nonrepresentable section on output
make: ***[libotcl.so]错误1
otcl-1.13make failed! Exiting ...
修改如下:
 cd ns-allinone-2.34/otcl-1.13
$ gedit configure.in 把77行处的:
SHLIB_LD="ld -shared",
改为;<span class="attribute" style="font-family: 微软雅黑, 宋体, Arial; line-height: 24px; background-color: rgb(255, 255, 255);">SHLIB_LD</span><span style="font-family: 微软雅黑, 宋体, Arial; line-height: 24px; background-color: rgb(255, 255, 255);">=</span><span class="attribute-value" style="font-family: 微软雅黑, 宋体, Arial; line-height: 24px; background-color: rgb(255, 255, 255);">"gcc -shared"</span>

$ gedit configure 

SHLIB_LD="ld -shared"

改为:

SHLIB_LD="gcc -shared"

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
修改:
<span style="font-family: Arial, Helvetica, sans-serif;">在ns-allinone-2.33/ ns-2.33/tools文件夹下,找到报错提示中的ranvar.cc文件,打开找到对应的219行删除::GaammaRandomVariable,保存,</span>
<span style="font-family: Arial, Helvetica, sans-serif;">即:将219行的</span>
<span style="font-family: Arial, Helvetica, sans-serif;">return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);</span>
<span style="font-family: Arial, Helvetica, sans-serif;">改为:</span>

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

三、

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

修改:

在ns-allinone-2.34\ns-2.34\mac\mac-802_11Ext.h 文件添加#include <cstddef>

四、
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’
修改:
在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的nakagami.cc文件,打开找到对应的183行删除::ErlangRandomVariable,保存,
即:将183行的<span style="font-family: Arial, Helvetica, sans-serif;">resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();</span>
改为:
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();
五、
make:***[linkstate/ls.o] 错误1
修改:
ns-2.35/linkstate/ls.h  第137行

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

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

 5、修改路径:根据自己放置路径修改 

vim ~/.bashrc

export PATH=/home/zys1/tupian/ns-allinone-2.33/bin:/home/zys1/tupian/ns-allinone-2.33/tcl8.4.18/unix:/home/zys1/tupian/ns-allinone-2.33/tk8.4.18/unix:$PATH


export LD_LIBRARY_PATH=/home/zys1/tupian/ns-allinone-2.33/otcl-1.13:/home/zys1/tupian/ns-allinone-2.33/lib:$LD_LIBRARY_PATH


export TCL_LIBRARY=/home/zys1/tupian/ns-allinone-2.33/tcl8.4.18/library



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值