您的位置:首页 > 其它

[转]Ubuntu 10.04安装ns2-2.34

2011-01-25 10:34 405 查看
试过成功了。

Ubuntu 10.04安装ns2-2.34

1、在官方网站上下载ns-allinone-2.34.tar.gz

2、更新系统。

在终端里输入:

$ sudo apt-get update #更新源列表
$sudo apt-get upgrade#更新已安装的包
$sudo apt-get dist-upgrade #更新软件,升级系统

3、安装几个编译必备的包

$ sudo apt-get install build-essential

$ sudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev

$ sudo apt-get install libxmu-dev libxmu-headers

4、进行安装

我的是把ns-allinone-2.34.tar.gz压缩包放在/home/duyaojun(自己的文件夹)下,

输入如下命令解压:

$ ls –l ns-allinone-2.34.tar.gz

$ tar zxf ns-allinone-2.34.tar.gz

运行安装命令:

$ cd ns-allinone-2.34

$ ./install

然后就开始安装ns-allinone-2.34,大概过几分钟,在结束时候突然报错:
ld -shared-o libotcl.so otcl.o
otcl.o: Infunction `OTclDispatch':
/usr/ns-allinone-2.34/otcl-1.13/otcl.c:495:undefined reference to `__stack_chk_fail_local'
otcl.o: Infunction `Otcl_Init':
/usr/ns-allinone-2.34/otcl-1.13/otcl.c:2284:undefined reference to `__stack_chk_fail_local'
ld:libotcl.so: hidden symbol `__stack_chk_fail_local' isn'tdefined
ld: finallink failed: Nonrepresentable section on output
make: ***[libotcl.so]错误1
otcl-1.13make failed! Exiting ...
Seehttp://www.isi.edu/nsnam/ns/ns-problems.html forproblems


分析错误原因:

这是因为gcc版本高了,gcc 4.0以前的版本是用ld –share来生成共享库的,但是到了gcc 4.0以后的版本,这个命令就改成了gcc –share。 在终端里输入gcc –v查看,我的版本是gcc version 4.4.3。

解决办法:

进入$ cd /home/duyaojun/ns-allinone-2.34/otcl-1.13

然后$ sudo gedit configure.in

把77行处的:

SHLIB_LD="ld -shared"

改为SHLIB_LD="gcc -shared",保存退出。

然后:$ sudo gedit configure

将6304行处的:

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />

SHLIB_LD="ld -shared",改为SHLIB_LD="gcc -shared",保存退出。

然后:

cd /home/duyaojun/ns-allinone-2.34

回到目录ns-allinone-2.34下运行

$ sudo ./install

如果正确可以看到提示:

Please put /home/duyaojun/ns-allinone-2.34/bin:/home/duyaojun/ns- allinone2.34/tcl8.4.18/unix:/home/duyaojun/ns-allinone- 2.34/tk8.4.18/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.
IMPORTANT NOTICES:
(1) You MUST put /home/duyaojun/ns-allinone-2.34/otcl-1.13, /home/duyaojun/ns-allinone-2.34/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 /home/duyaojun/ns-allinone-2.34/tcl8.4.18/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.34; ./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.

这个是因为没有配置环境变量。

cd /home/duyaojun

$ sudo gedit .bashrc

在文件末尾加入:
PATH="$PATH:/home/duyaojun/ns-allinone2.34/bin:/home/duyaojun/ns-allinone-2.34/tcl8.4.18/unix:/home/duyaojun/ns-allinone-2.34/tk8.4.18/unix"
LD_LIBRARY_PATH="
/home/duyaojun/ns-allinone-2.34/otcl-1.13:/home/duyaojun/ns-allinone-2.34/lib"
TCL_LIBRARY="$TCL_LIBRARY:
/home/duyaojun/ns-allinone-2.34/tcl8.4.18/library"
保存退出。

5、简单测试

(1)、打开一个新的终端

(2)、输入ns并回车

$ ns

(如果正常,会出现“%”操作提示符)

(3)、输入一段测试用的Tcl脚本代码进行测试

% puts“Hello World”

Hello World

%
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: