Today when I tried to install ns-allinone-2.34 on Ubuntu 11.04 and ran ‘./install’, an ERROR occurs. It goes,
> g++ -c -g -O2 -Wall …tools/ranvar.o tools/ranvar.cc
> 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[1]: *** [tools/ranvar.o] Error 1
Then after some googling, I found http://erl1.wordpress.com/2011/05/12/installing-ns-2-34-on-ubuntu-11-04/.
The solution it provides solved my problem and NS2.34 could run correctly on my machine now.
I’d like to paste the piece of blog here for reference:
———————————————————————————————
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.
———————————————————————————————–
My thanks to Erlend’s Lookout Post.
Recent Comments