[Linux的平常] CentOS安裝NS2.35

官網上下載確實很慢  在這裏上傳到網盤上:html

連接: 點我下載shell

提取碼: uk1fvim

安裝過程:windows

參考了兩篇文章:bash

https://blog.csdn.net/Jo_Stacey/article/details/83243009編輯器

https://stackoverflow.com/questions/26616003/shopt-command-not-found-in-bashrc-after-shell-updationpost

第一步:下載NS-2.35的安裝包(不是windows下的安裝包,請注意後綴是 *tar.gzui

能夠在官網下載,也能夠在上面的百度網盤下載。由於我用的是虛擬機,因此下載到物理機上而後直接拖過去複製。用 Linux 物理機的話請自行想辦法下載。this

第二步:解壓文件並安裝相應依賴:spa

①進入到你下載的安裝包的路徑 如:

$ cd /home/download  /*只是一個參考 具體進入到哪一個目錄按照你本身的安裝包存儲目錄*/

②解壓壓縮包:

$ tar -zxvf ns-allinone-2.35.tar.gz

③安裝相應依賴:(注:# 是在 root 模式下進行)/* 若是你的 yum 下載速度很慢 請參考我寫的另一篇文章,CentOS yum 換源*/

# yum install libX11-devel* -y
# yum install xorg-x11-proto-devel* -y
# yum install libXt-devel* -y
# yum install libXmu-devel* -y

第三步:建立安裝目錄:

# mkdir /usr/ns-2/NS-2 -p

②把剛剛解壓獲得的 ns-allinone-2.35 文件夾移動到建立的目錄下:

# mv /home/download /usr/ns-2/NS-2/  <=注意,一切不以 / 開頭的路徑都是相對路徑

第四步:修改配置文件(這個是重點,若是不修改會報錯,若是編譯報錯請務必仔細看這一步)

# vim /usr/ns-2/NS-2/ns-allinone-2.35/ns-2.35/linkstate/ls.h

把代碼的 137 行(vim 編輯器右下角會提示你光標移動到哪一行,按一下鍵盤上的 i 鍵進入編輯模式)中的 erase 改做 this->erase

第五步:安裝:

①進入到安裝目錄下:

# cd /usr/ns-2/NS-2/ns-allinone-2.35

②編譯安裝

# ./install

如出現如下內容則表示安裝成功


Please put /usr/ns-2/NS-2/ns-allinone-2.35/bin:/usr/ns-2/NS-2/ns-allinone-2.35/tcl8.5.10/unix:/usr/ns-2/NS-2/ns-allinone-2.35/tk8.5.10/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph. IMPORTANT NOTICES: (1) You MUST put /usr/ns-2/NS-2/ns-allinone-2.35/otcl-1.14, /usr/ns-2/NS-2/ns-allinone-2.35/lib, into your LD_LIBRARY_PATH environment variable. If it complains about X libraries, add path to your X libraries into LD_LIBRARY_PATH. If you are using csh, you can set it like: setenv LD_LIBRARY_PATH <paths> If you are using sh, you can set it like: export LD_LIBRARY_PATH=<paths> (2) You MUST put /usr/ns-2/NS-2/ns-allinone-2.35/tcl8.5.10/library into your TCL_LIBRARY environmental variable. Otherwise ns/nam will complain during startup. After these steps, you can now run the ns validation suite with cd ns-2.35; ./validate For trouble shooting, please first read ns problems page http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive for related posts.

第六步:配置環境變量:

①進入配置文件:

# gedit ~/.bashrc

②添加如下內容:

export PATH="$PATH:/usr/ns-2/NS-2/ns-allinone-2.35/bin:/usr/ns-2/NS-2/ns-allinone-2.35/tcl8.5.10/unix:/usr/ns-2/NS-2/ns-allinone-2.35/tk8.5.10/unix"

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/ns-2/NS-2/ns-allinone-2.35/otcl-1.14:/usr/ns-2/NS-2/ns-allinone-2.35/lib"

export TCL_LIBRARY="$TCL_LIBRARY:/usr/ns-2/NS-2/ns-allinone-2.35/tcl8.5.10/library"

保存退出 生效

③更新bash:

# source ~/.bashrc

好,到這裏可能有人會出錯:

錯誤1:shopt 命令未定義、shopt command is not found...等等

分析:極可能是由於安裝了 zsh 因此你更新 bash 源是沒有用的,因此第六步請按照如下步驟來:

①進入配置文件:

# gedit ~/.zshrc

②一樣添加上述內容:略

③更新 zsh:

# source ~/.zshrc

第七步:檢測 NS2 環境:

在終端輸入 ns ,若出現 ,而且輸入 nam 後能夠打開 NAM 程序,說明環境構建成功。

安裝gawk:https://blog.csdn.net/weixin_34185364/article/details/85780590

相關文章
相關標籤/搜索