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",
改为;SHLIB_LD="gcc -shared"

$ 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
修改:
在ns-allinone-2.33/ ns-2.33/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_);

三、

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

四、
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行的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();
五、
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



你可能感兴趣的:(WSN)