1.去http://www.isi.edu/nsnam/dist/上下载ns-allinone-2.28.tar.gz
2.用Ubuntu终端下载软件包: sudo apt-get install tcl8.4 sudo apt-get install tcl8.4-dev sudo apt-get install tk8.4 sudo apt-get install tk8.4-dev sudo apt-get install libxmu-dev sudo apt-get install g++ sudo apt-get install build-essential
3.解压缩ns的压缩包,建议放到 /home/(用户名) 下,终端直接运行./install,
会提示如下错误 checking system version (for dynamic loading)... ./configure: 1: Syntax error: Unterminated quoted string tcl8.3.2 configuration failed! Exiting
4.终端中,依次输入以下命令,
将显示的对应的文件位置的system=MP-RAS-`awk '{print }' /etc/.relid'` 更改为system=MP-RAS-`awk '{print }' /etc/.relid`(即去掉后面的')
grep 'system=MP-RAS-' */* -n
grep 'system=MP-RAS-' */*/* -n
grep 'system=MP-RAS-' */*/*/* -n
5.NS-2.28 AllInOne HOWTO This HOWTO covers installation on Ubuntu Linux.
Get the allinone source.
$ cd ~lucsp
$ wget http://www.isi.edu/nsnam/dist/ns-allinone-2.28.tar.gz Modify build for GDB debugger.
$ tar xzf ns-allinone-2.28.tar.gz $ cd ns-allinone-2.28
$ vim install
Add the –enable-synbols option on line 408
so, ./configure –enable-gcc –disable-shared –prefix=$CUR_PATH || die “tcl8.3.2 configuration failed! Exiting …” becomes, ./configure –-enable-symbols –enable-gcc –disable-shared –prefix=$CUR_PATH || die “tcl8.3.2 configuration failed! Exiting …”
Add the –enable-debug option to line 498 so, ./configure || die “tclcl-$TCLCLVER configuration failed! Exiting …” becomes, ./configure -–enable-debug || die “tclcl-$TCLCLVER configuration failed! Exiting …”
$ cd ns-2.28
$ vim Makefile.in Add the -g option to line 82 so, CFLAGS = $(CCOPT) $(DEFINE) becomes, CFLAGS = -g $(CCOPT) $(DEFINE)
X11/Intrinsic.h is required by otcl1-9 but is not in libx11-dev but is in libxt-dev.
$ sudo apt-get install -f libxt-dev libxt6 libsm-dev libsm6 libice-dev libice6 /usr/X11R6/include/X11/Xmu/WinUtil.h is required by nam-1.1.
$ sudo apt-get install libxmu-dev xgraph Makefile requires modification.
$ cd ../xgraph-12.1
$ ./configure
$ vim Makefile Add -L/usr/X11R6/lib on line 85 so, xgraph_LDADD = $(ADDITIONAL_LIBS) $(X_LIBS) $(X_PRE_LIBS) $(X_EXTRA_LIBS) -lX11 -lm becomes, xgraph_LDADD = $(ADDITIONAL_LIBS) $(X_LIBS) $(X_PRE_LIBS) $(X_EXTRA_LIBS) -L/usr/X11R6/lib -lX11 -lm
gt-itm requires a bin dir to be created.
$ cd ../gt-itm
$ mkdir bin
$ cd src
$ make gt-itm and sgb2ns require sgb.
$ sudo apt-get install sgb
gt-itm and sgb2ns require libgb.a to be at /home/lucsp/ns-allinone-2.28/gt-itm/lib.
$ mkdir lib
$ sudo ln -s usr/lib/libgb.a /home/lucsp/ns-allinone-2.28/gt-itm/lib
Fix pedantic gcc 3.3.5
$ cd src
$ vim eval.c
On line 162,
the printf function argument must be on a single line. printf(” and %d (this ends a connected component of the graph)n”, idx(g, artic_pt)); Compile NS-2.28.
$ cd ..
$ ./install
&> compile.out Environmental variables. 如果gcc版本比较新的话 需要修改otcl目录下的configure和configure.in 将其中的ld -shared 改成 gcc -shared
$ vim NS2.sh
#!/bin/sh
# LD_LIBRARY_PATH OTCL_LIB=/home/lucsp/ns-allinone-2.28/otcl-1.9 NS2_LIB=/home/lucsp/ns-allinone-2.28/lib X11_LIB=/usr/X11R6/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:
$OTCL_LIB:$NS2_LIB:$X11_LIB:/usr/local/lib # TCL_LIBRARY export TCL_LIBRARY=/home/lucsp/ns-allinone-2.28/tcl8.4.5/library:/usr/lib # PATH XGRAPH=/home/lucsp/ns-allinone-2.28/bin:/home/lucsp/ns-allinone-2.28/tcl8.4.5/unix:/home/lucsp/ns-allinone-2.28/tk8.4.5/unix PATH=$PATH:$XGRAPH:/home/lucsp/ns-allinone-2.28/ns-2.28/