Friday 7 November 2014

Error during NS-2.34 installation in Ubuntu

When installing NS-2.34 in ubuntu, you might get following compilation errors.


1. 
ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined
ld: final link failed: Bad value
make: *** [libotcl.so] Error 1
otcl-1.13 make failed! Exiting ...


2. 
tools/ranvar.cc: In member function ‘virtual double GammaRandomVariable::value()’:
tools/ranvar.cc:219:70: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly [-fpermissive]
tools/ranvar.cc:219:70: error:   for a function-style cast, remove the redundant ‘::GammaRandomVariable’ [-fpermissive]
make: *** [tools/ranvar.o] Error 1


3.
In file included from mac/mac-802_11Ext.cc:66:0:
mac/mac-802_11Ext.h: In member function ‘u_int32_t PHY_MIBExt::getHdrLen11()’:
mac/mac-802_11Ext.h:175:19: error: expected primary-expression before ‘struct’
mac/mac-802_11Ext.h:175:41: error: ‘dh_body’ was not declared in this scope
mac/mac-802_11Ext.h:175:51: error: ‘offsetof’ was not declared in this scope
mac/mac-802_11Ext.h:177:3: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [mac/mac-802_11Ext.o] Error 1
Ns make failed!


4.
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 [-fpermissive]
mobile/nakagami.cc:183:73: error:   for a function-style cast, remove the redundant ‘::ErlangRandomVariable’ [-fpermissive]
mobile/nakagami.cc:185:67: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly [-fpermissive]
mobile/nakagami.cc:185:67: error:   for a function-style cast, remove the redundant ‘::GammaRandomVariable’ [-fpermissive]
make: *** [mobile/nakagami.o] Error 1


5.
other compilation error


What ever is the compilation error, the error is most probably due to the old version of gcc compiler.


Solution:



Step 1. 
first install the latest compiler
~$ sudo apt-get install gcc-4.4 g++-4.4


Step 2. 
The next step is to edit line 270 in tcl8.4.18/unix/Makefile.in.

~$ gedit /your/path/ns-allinone-2.34/tcl8.4.18/Makefile.in

SOLVED:
#CC = @CC@
CC = @CC@-4.4

save and exit

Step 3. 
To used gcc-4.4 and g++-4.4 as compiler to compile ns-allinone-2.34, change the line 36-37 in ns-2.34/Makefile.in.

~$ gedit /your/path/ns-allinone-2.34/ns-2.34/Makefile.in

SOLVED:
#CC = @CC@ 
#CPP = @CXX@
CC = @CC@-4.4
CPP = @CXX@-4.4

save and exit


Step 4. 
now go to /your/path/ns-allinone-2.34
./install


Thats all...now your ns2 should install well. Good luck.