天天看點

Ubuntu上安裝ns2-2.34

下載下傳ns-allinone-2.34

$ tar zxf ns-allinone-2.34.tar.gz

sudo apt-get install build-essential    # gcc

sudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev   # for tcl and tk

sudo apt-get install libxmu-dev libxmu-headers    # for nam

./install

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 

将6304行處的:

shlib_ld="ld -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 make failed! see http://www.isi.edu/nsnam/ns/ns-problems.html for problems

在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 <cstddef>

然後重新安裝

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();

設定環境變量

# gedit ~/.bashrc 

export ld_library_path=/root/ns2/ns-allinone-2.34/otcl-1.13:/root/ns2/ns-allinone-2.34/lib:ldlibrarypathexporttcllibrary=/root/ns2/ns−allinone−2.34/tcl8.4.18/libraryexportpath=/root/ns2/ns−allinone−2.34/bin:/root/ns2/ns−allinone−2.34/tcl8.4.18/unix:/root/ns2/ns−allinone−2.34/tk8.4.18/unix:ldlibrarypathexporttcllibrary=/root/ns2/ns−allinone−2.34/tcl8.4.18/libraryexportpath=/root/ns2/ns−allinone−2.34/bin:/root/ns2/ns−allinone−2.34/tcl8.4.18/unix:/root/ns2/ns−allinone−2.34/tk8.4.18/unix:path

Ubuntu上安裝ns2-2.34