NS2的下载地址
http://www.isi.edu/nsnam/ns/ns-build.html
NS2的安装分为2种
第一种是采用allinone包,因为NS2的依赖包有很多,要成功安装NS2需要很多库,为了便利安装,这些库被集中起来放在allinone包里面。
第二种是采用各个库分别安装。
首先必须保证一些基本的库被安装 (包括gcc和X11库)
下载ns-allinone-2.34.tar.gz
tar xzvf ns-allinone-2.34.tar.gz
cd ns-allinone-2.34
./install
这样如果不出意外就能成功安装ns2。
ns2的图形界面安装:
cd xgraph-12.1
这里注意:对于2.34版本的allinone版本会出现如下的错误
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -c dialog.c
dialog.c: In function ‘make_msg_box’:
dialog.c:780: warning: passing argument 2 of ‘getline’ from incompatible pointer type
/usr/include/stdio.h:653: note: expected ‘size_t * __restrict__’ but argument is of type ‘char *’
dialog.c:780: error: too few arguments to function ‘getline’
dialog.c: In function ‘getline’:
dialog.c:899: error: argument ‘lptr’ doesn’t match prototype
/usr/include/stdio.h:653: error: prototype declaration
dialog.c:899: error: number of arguments doesn’t match prototype
/usr/include/stdio.h:653: error: prototype declaration
make: *** [dialog.o] Error 1
最简单的修复方法是
打开 ns-allinone-2.34/xgraph-12.1/dialog.c
将 2处的getline换成其他的字符如getmyline后保存退出
运行命令./configure即可正确安装
第一种方法我已经成功安装在suse11.2,x86机器上
但是安装suse 10.2 x86_64的时候失败了。
提示错误如下
g++ -c -Wall -Wno-write-strings -DTCP_DELAY_BIND_ALL -DNO_TK -DTCLCL_CLASSINSTVAR -DNDEBUG -DLINUX_TCP_HEADER -DUSE_SHM -DHAVE_LIBTCLCL -DHAVE_TCLCL_H -DHAVE_LIBOTCL1_13 -DHAVE_OTCL_H -DHAVE_LIBTK8_4 -DHAVE_TK_H -DHAVE_LIBTCL8_4 -DHAVE_TCLINT_H -DHAVE_TCL_H -DHAVE_CONFIG_H -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=std -DUSE_SINGLE_ADDRESS_SPACE -Drng_test -I. -I. -I/opt/ns2/2.34/allinone/tclcl-1.19 -I/opt/ns2/2.34/allinone/otcl-1.13 -I/opt/ns2/2.34/allinone/include -I/opt/ns2/2.34/allinone/include -I/opt/ns2/2.34/allinone/include -I/usr/include/pcap -I./tcp -I./sctp -I./common -I./link -I./queue -I./adc -I./apps -I./mac -I./mobile -I./trace -I./routing -I./tools -I./classifier -I./mcast -I./diffusion3/lib/main -I./diffusion3/lib -I./diffusion3/lib/nr -I./diffusion3/ns -I./diffusion3/filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -o tools/random.o tools/random.cc
tools/rng.h:104: error: expected class-name before { token
tools/rng.h:369: error:FILE has not been declared
tools/random.cc:50: error: RANDOM_RETURN_TYPE?does not name a type
make: *** [tools/random.o] Error 1
Ns make failed!
解决办法:
未解决!!!!!!!!!!!!!!!!!!!!!!!!!
采用第二种安装
按照传统的方法分别安装tcl,tk,otcl,tclcl。
./configure --prefix=XXXX
make
make install
需要注意的是,这里如果会出现几个错误
错误一:
ld:not found lX11
解决办法是:
ln -s /usr/X11R6/lib64/libX11.a /usr/local/lib64/libX11.a
ln -s /usr/X11R6/lib64/libX11.so /usr/local/lib64/libX11.so
ln -s /usr/X11R6/lib64/libX11.so.6 /usr/local/lib64/libX11.so.6
ln -s /usr/X11R6/lib64/libX11.so.6.2 /usr/local/lib64/libX11.so.6.2
错误二:
checking Tcl http.tcl library... configure: error: Couldn't find http.tcl in /http /http2.4 /http2.3 /http2.1 /http2.0
解决办法是 加 --with-tcl=“tcl的源码路径”
这些类库有的库是依赖于刚刚安装的库,这时候都需要加上 --with-XX的形式将安装源代码路径输入进去(注意不是安装后的路径)
错误三:
在suse 10.2,x86_64平台上还是会出现上面第一种安装的时候所出现的错误。
解决办法:
未解决!!!!!!!!!!!!!!!!!!!!!!!!!