2010年3月16日 星期二

如何在 ubuntu 9.10,安裝 ns-2.34

參考網頁:
http://ns-2.blogspot.com/2009/11/how-to-install-ns-234-on-ubuntu-910.html

第一步:從 Sourceforge下載ns-allinone-2.34.tar.gz

第二步:放在local端,ex: /home/NS2,解壓縮
$ cd /home/NS2
$ tar -zxvf ns-allinone-2.34.tar.gz

第三步:安裝一些其他必要的檔案
$ sudo apt-get install build-essential autoconf automake libxmu-dev

第四步:安裝ns2
$ cd ns-allinone-2.34
$ ./install

第五步:如果出錯了,是由於otcl-1.13 和 gcc-4.4.1/g++-4.4.1 (ubuntu 9.10內建的版本)不太合,無法compile,所以需要改安裝 g++-4.3版
$ sudo apt-get install g++-4.3
$ CC=gcc-4.3 CXX=g++-4.3 ./install

接著,還要再修改otcl資料夾內的Makefile.in
$ cd otcl-1.13
$ sudo gedit Makefile.in

把第7行的 CC= 改掉
From :
CC= @CC@

To:
CC= gcc-4.3

存檔後離開。

$ cd .. (應該會回到 ns-allinone-2.34資料夾底下)
$ ./install

第六步:修改環境變數、path
$ gedit ~/.bashrc

將以下幾行加在檔案的最後面,/home/NS2/ 則必須根據你自己的檔案名做更改。
ns2安裝完成後,最後面會提醒你要修改.bashrc,如果不知道/home/NS2/ 要替換成什麼,請參考ns2給的path。

# LD_LIBRARY_PATH
OTCL_LIB=/home/NS2/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/NS2/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=/home/NS2/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/simulator/ns-allinone-2.34/bin:/home/simulator/ns-allinone-2.34/tcl8.4.18/unix:/home/simulator/ns-allinone-2.34/tk8.4.18/unix
NS=/home/simulator/ns-allinone-2.34/ns-2.34/
NAM=/home/simulator/ns-allinone-2.34/nam-1.14/
export PATH=$PATH:$XGRAPH:$NS:$NAM

第七步:驗證是否安裝成功
$ cd ns-2.34
$ ./validate

完成後會出現:
validate overall report: all tests passed

恭喜 :)
--
如果仍然不行,請參考這個網頁所給的第二種方法,然後再./install一次
Related Posts with Thumbnails