作者:手机用户2502920971 | 来源:互联网 | 2023-05-19 13:11
在Ubuntu 11.04中安装ns-2.33,以前在Ubuntu-10.10安装ns-2.33没有遇到过这种错误,后来升级了一下Ubuntu的版本,就会出现以下错误。
可参考以下网址上说的解决方法:
2011-06/36779p3.htm
1.错误一:安装NS2.33过程中出现如下的错误:
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.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_);
-----------------------------------------------------------------------------------------------------------------------------------------------
2.错误二:重新在ns目录下键入$ ./install安装,再次出现同类问题时,
如:
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.33/ ns-2.33/ mobile文件夹下,找到报错提示中的nakagami.cc文件,打开找到对应的183行删除::ErlangRandomVariable,保存,
即:将183行的
resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();
改为:
resultPower = ErlangRandomVariable(Pr/m, int_m).value();
在ns-allinone-2.33/ ns-2.33/ mobile文件夹下,找到报错提示中的nakagami.cc文件,打开找到对应的185行删除::GammaRandomVariable,保存,
即:将185行的
resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();
改为:
resultPower = GammaRandomVariable(m, Pr/m).value();
重新在ns目录下键入$ ./install安装,再次出现同类问题时,仿照此次解决方法,找到对应的文件和行数,修改即可。直到安装成功。