1.安装必备包

Before install NS2, you have to install some essential softwares:

sudo apt-get install tcl8.5-dev tk8.5-dev
sudo apt-get install build-essential autoconf automake 
sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev

2.配置

 

2.1) Modify the makefile (NOTICE: I use “vi” for an editor, you can use “gedit” instead)

vi /home/stan/ns-allinone-2.35/otcl-1.14/Makefile.in

2.2) Change CC = @CC@ to CC = @CC@ -V 4.5

(For changing this because the gcc complier in Ubuntu 11.04 is version 4.5, however NS2 only supports gcc-4.3 below. NOTICE the V is capital.)

3.安装

 

 

Install NS2:

cd /home/stan/ns-allinone-2.35
 
  

3.1) Modify  .bahrc

vi /home/stan/.bashrc

3.2) Go to the last line and add the scripts below:

export PATH=$PATH:/home/stan/ns-allinone-2.35/bin:/home/stan/ns-allinone-2.35/tcl8.5.10/unix:/home/stan/ns-allinone-2.35/tk8.5.10/unix export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/stan/ns-allinone-2.35/otcl-1.14:/home/stan/ns-allinone-2.35/libexport TCL_LIBRARY=$TCL_LIBRARY:/home/stan/ns-allinone-2.35/tcl8.5.10/library export TCL_LIBRARY=$TCL_LIBRARY:/home/stan/ns-allinone-2.35/tcl8.5.10/library 
 cd /home/stan source .bashrc 
which ns If it shows /home/stan/ns-allinone-2.35/bin/ns, it works