$ wget http://nchc.dl.sourceforge.net/sourceforge/nsnam/ns-allinone-2.34.tar.gz安裝同樣是在進行中,OTCL出錯,退出,原因未知(“otcl-1.13 make failed! Exiting …”不知其所以然,google之)
$ tar -xzvf ns-allinone-2.34.tar.gz
$ cd ns-allinone-2.34
$ sudo apt-get install build-essential autoconf automake libxmu-dev
$ ./install
$ gedit ~/.bashrc
末尾添加:
# LD_LIBRARY_PATH
OTCL_LIB=/your/path/ns-allinone-2.34/otcl-1.13
NS2_LIB=/your/path/ns-allinone-2.34/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB
# TCL_LIBRARY
TCL_LIB=/your/path/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.18/unix:/your/path/ns-allinone-2.34/tk8.4.18/unix
NS=/your/path/ns-allinone-2.34/ns-2.34/
NAM=/your/path/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM
為使修改的環境變量立即生效,執行
$ source ~/.bashrc
至此ok
$ns
% 出現,證明一切徹底ok
試了一個例子通過。
轉: eclipse調試ns程序
Eclipse
Open Eclipse
Set the workspace as the ns installation path( /home/username/ns-allinone-2.34 ) by selecting File -> Switch Workspace
Choose File -> New -> Project -> C++ Project
Select Project Type as Makefile Project -> Empty C++ Project.
Toolchains: Linux GCC
Enter Project Name as ns-2.34
Uncheck “Use default location” then browse to the directory NS-2 source directory ( …/ns-allione-2.34/ns-2.34 )
Select “Next” and “Finish.
From the workspace, Selecting the NS-2 Project and choosing Project -> Build All should not give Error.
Running the project must open the console with the NS-2 prompt, %
Setting Debug Configuration:
Select Run -> Debug Configurations
Choose C/C++ Application. Type in any name.
Under the Main tab, Choose the following:
Project as ns-2.34.
C/C++ Application as ns. (Search Project and Choose this)
Under the Debugger tab, choose GDB Debugger. Uncheck the “Stop on startup at” option.
Apply and Debug.