歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> ns2.34_Ubuntu安裝記錄

ns2.34_Ubuntu安裝記錄

日期:2017/2/28 16:34:03   编辑:Linux教程
原先是在win_cygwin下安裝的,還是比較順,基本沒出問題。最近VisualBox+Ubuntu玩玩看,准備在上面安裝NS2,順便學習一下Linux。

學習需要2.31,安裝有問題,沒仔細看出錯信息,otcl有誤,魯莽認為版本有問題,下ns2.34,目前最新,09年。估計ns3風生水起,2停止release了。

轉入正題。
$ wget http://nchc.dl.sourceforge.net/sourceforge/nsnam/ns-allinone-2.34.tar.gz
$ tar -xzvf ns-allinone-2.34.tar.gz
$ cd ns-allinone-2.34
$ sudo apt-get install build-essential autoconf automake libxmu-dev
$ ./install
安裝同樣是在進行中,OTCL出錯,退出,原因未知(“otcl-1.13 make failed! Exiting …”不知其所以然,google之)
解決方法:
ns-allinone-2.34/ns-2.34中找到 Makefile.in,修改

CC = @CC@ 改為 CC = gcc-4.3
CPP = @CXX@ 改為 CPP = g++-4.3

OS中有gcc,g++ ?
$ sudo apt-get install g++-4.3
$ CC=gcc-4.3 CXX=g++-4.3 ./install

執行。。。。。。
中間沒看清,./install 重新工作,安裝結束, 對Linix機理還是不清楚,www.linuxidc.com慚愧!

修給環境變量:
$ 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.

Copyright © Linux教程網 All Rights Reserved