1、首先是下载ns-allinone-2.33.tar.gz,地址为
tar -zxvf ns-allinone-2.33.tar.gz
2、安装所依赖的数据包
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
3、gcc 4.0版本以前是用ld -share来生成共享库的,但是到了4.0以上的版本这个命令改为了gcc -share
进入ns-allinone-2.33/otcl-1.13
sudo gedit configure.in
把77行处的SHLIB_LD="ld -shared"改为SHLIB_LD="gcc -shared"
sudo gedit configure
把5518行的SHLIB_LD="ld -shared"改为SHLIB_LD="gcc -shared"
保存退出
4 、安装
./install
5、设置环境变量/etc/environment
PATH="$PATH:/home/yyang/ns-allinone-2.33/bin:/home/yyang/ns-allinone-2.33/tcl8.4.18/unix:/home/yyang/ns-allinone-2.33/tk8.4.18/unix"
LD_LIBRARY_PATH="/home/yyang/ns-allinone-2.33/otcl-1.13:/home/yyang/ns-allinone-2.33/lib"
TCL_LIBRARY="$TCL_LIBRARY:/home/yyang/ns-allinone-2.33/tcl8.4.18/library"
6、试运行
打开一个新终端,输入ns命令,倘若出现%,则说明安装成功。
cd /ns-allinone-2.33/ns-2.33
然后运行
./validate
7、有可能需要打补丁。在于ns2.33中,nam调用的tk组件和xproto-7.0.13不兼容,因此要打补丁,解决步骤如下(注:补丁可以到这里下载http://bugs.gentoo.org/show_bug.cgi?id=225999)
1)新建一个文档,名为“tk-8.4-lastevent.patch”,并将以下内容复制到其中:
--- generic/tk.h.orig 2008-02-06 16:31:40.000000000 +0100
+++ generic/tk.h 2008-07-24 08:21:46.000000000 +0200
@@ -635,17 +635,15 @@
*
*---------------------------------------------------------------------------
*/
-#define VirtualEvent (LASTEvent)
-#define ActivateNotify (LASTEvent + 1)
-#define DeactivateNotify (LASTEvent + 2)
-#define MouseWheelEvent (LASTEvent + 3)
-#define TK_LASTEVENT (LASTEvent + 4)
+#define VirtualEvent (MappingNotify + 1)
+#define ActivateNotify (MappingNotify + 2)
+#define DeactivateNotify (MappingNotify + 3)
+#define MouseWheelEvent (MappingNotify + 4)
+#define TK_LASTEVENT (MappingNotify + 5)
#define MouseWheelMask (1L << 28)
-
#define ActivateMask (1L << 29)
#define VirtualEventMask (1L << 30)
-#define TK_LASTEVENT (LASTEvent + 4)
/*
把这个文件移动至ns目录下tk8.4.18下,在终端运行命令:
$cd ns-allinone-2.33/tk8.4.18
$patch –p1<tk-8.4-lastevent.patch
然后在提示patch哪个文件的时候,输入generic/tk.h
2)打补丁打补丁tk-8.4.18-tkBind.patch
创建新文件(名为tk-8.4.18-tkBind.patch),复制以下内容:
--- tk8.4.18-orig/generic/tkBind.c 2006-07-21 08:26:54.000000000 +0200
+++ tk8.4.18/generic/tkBind.c 2008-07-05 12:17:10.000000000 +0200
@@ -586,6 +586,9 @@
/* ColormapNotify */ COLORMAP,
/* ClientMessage */ 0,
/* MappingNotify */ 0,
+#ifdef GenericEvent
+ /* GenericEvent */ 0,
+#endif
/* VirtualEvent */ VIRTUAL,
/* Activate */ ACTIVATE,
/* Deactivate */ ACTIVATE,
将文件tk-8.4.18-tkBind.patch移至ns-allinone-2.33目录下,并运行如下命令:
$patch -p0 <tk-8.4.18-tkBind.patch
8、重新安装
./install