2014-12-30 00:00:00
来 源
中存储网
Ubuntu
在Ubuntu 11.04中安装ns-2.33,以前在Ubuntu-10.10安装ns-2.33没有遇到过这种错误,后来升级了一下Ubuntu的版本,就会出现以下错误。 1.错误一:安装NS2.33过程中出现如下的错误: tools/ranvar.cc: In member function virtual double GammaRandomVariable:

在Ubuntu 11.04中安装ns-2.33,以前在Ubuntu-10.10安装ns-2.33没有遇到过这种错误,后来升级了一下Ubuntu的版本,就会出现以下错误。

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安装,再次出现同类问题时,仿照此次解决方法,找到对应的文件和行数,修改即可。直到安装成功。

3.错误三:安装成功之后,输入命令ns之后出现如下错误:

*** buffer overflow detected ***: ns terminated

======= Backtrace: =========

/lib/i386-linux-gnu/libc.so.6(__fortify_fail+0x50)[0x451df0]

/lib/i386-linux-gnu/libc.so.6(+0xe4cca)[0x450cca]

/lib/i386-linux-gnu/libc.so.6(__strcpy_chk+0x3f)[0x45005f]

ns(TclTraceVariableObjCmd+0x420)[0x83adb00]

ns(Tcl_TraceObjCmd+0x469)[0x83b2989]

ns(TclEvalObjvInternal+0x37b)[0x839f2bb]

ns(Tcl_EvalEx+0x419)[0x83a11a9]

ns(Tcl_Eval+0x3c)[0x83a14cc]

ns(Tcl_GlobalEval+0x36)[0x83a2086]

ns(_ZN3Tcl4evalEPc+0x1b)[0x839438b]

ns(_ZN3Tcl5evalcEPKc+0xb3)[0x839435d]

ns(_ZN11EmbeddedTcl4loadEv+0x1d)[0x83952cf]

ns(Tcl_AppInit+0xb5)[0x83940ab]

ns(Tcl_Main+0x285)[0x83eb0c5]

ns(nslibmain+0x20)[0x8393fd4]

ns(main+0x1b)[0x8394147]

/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x382e37]

ns[0x81a8481]

======= Memory map: ========

00c38000-00c54000 r-xp 00000000 08:01 19439     /lib/i386-linux-gnu/ld-2.13.so

00c54000-00c55000 r--p 0001b000 08:01 19439     /lib/i386-linux-gnu/ld-2.13.so

00c55000-00c56000 rw-p 0001c000 08:01 19439     /lib/i386-linux-gnu/ld-2.13.so

00c5a000-00c5c000 r-xp 00000000 08:01 261673    /usr/lib/i386-linux-gnu/libXau.so.6.0.0

00c5c000-00c5d000 r--p 00001000 08:01 261673    /usr/lib/i386-linux-gnu/libXau.so.6.0.0

00c5d000-00c5e000 rw-p 00002000 08:01 261673    /usr/lib/i386-linux-gnu/libXau.so.6.0.0

00cc0000-00ccd000 r-xp 00000000 08:01 268150    /usr/lib/i386-linux-gnu/libXext.so.6.4.0

00ccd000-00cce000 r--p 0000c000 08:01 268150    /usr/lib/i386-linux-gnu/libXext.so.6.4.0

00cce000-00ccf000 rw-p 0000d000 08:01 268150    /usr/lib/i386-linux-gnu/libXext.so.6.4.0

00ef9000-00f0c000 r-xp 00000000 08:01 19425     /lib/i386-linux-gnu/libnsl-2.13.so

00f0c000-00f0d000 r--p 00012000 08:01 19425     /lib/i386-linux-gnu/libnsl-2.13.so

00f0d000-00f0e000 rw-p 00013000 08:01 19425     /lib/i386-linux-gnu/libnsl-2.13.so

.......(注:这里省略了部分错误提示语句)

bfbbb000-bfbdc000 rw-p 00000000 00:00 0         [stack]

已放弃

这是gcc的版本问题,解决方法如下:

1.安装gcc-4.4

输入:sudo apt-get intall gcc-4.4

2.安装g++-4.4

输入:sudo apt-get intall g++-4.4

3.修改tcl8.4.18/unix文件夹下的文件Makefile.in

将Makefile.in的270行:

CC = @CC@

修改为:

CC = @CC@ -V 4.4

注意是大写的‘V’,这样gcc使用的参数版本为4.4。

重新安装ns2.33。

Install the development files for X Windows plus the g++ compiler:
sudo apt-get install xorg-dev g++ xgraph

Fix the error in the linking of otcl by editing line 6304 of otcl-1.13/configure so that it reads
SHLIB_LD="gcc -shared"
instead of
SHLIB_LD="ld -shared"

Then, edit the file ns-2.34/tools/ranvar.cc and change the line 219 from
return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
to
return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);

Next, change the lines 183 and 185 in file ns-2.34/mobile/nakagami.cc to read
resultPower = ErlangRandomVariable(Pr/m, int_m).value();
and
resultPower = GammaRandomVariable(m, Pr/m).value();

Now the code will compile if you run ./install. However, you may not be able to run the ns executable. If you get an error stating that there has been a buffer overflow *** buffer overflow detected ***: ./ns terminated including a backtrace, ending with the word , during the execution, you need to do the following to make it work:

Install gcc-4.4 and g++-4.4 including dependencies from the Synaptic Package Manager. You can run Synaptic Package Manager either through the Applications button (the magnifying glass with a + inside), or run it from the command line:
$ sudo synaptic

Change the line 270 in tcl8.4.18/unix/Makefile.in that reads
CC = @CC@
so it appends the version parameter for version 4.4:
CC = @CC@ -V 4.4
Make sure it is a capital V.

Finally, run ./install from the ns-allinone-2.34 top folder again.

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。