转自http://blog.csdn.net/windows00/archive/2009/12/08/4967801.aspx
个人觉得写得不错,希望能给大家带来帮助
初次安装NS2可能会遇到一些问题。为了顺利安装,在这篇文章中,我叙述了在安装NS2的过程中所遇到的问题,以及解决这些问题的办法。
描述
- 虚拟机环境:VirtualBox 3.1.0 r55467
- 操作系统:ubuntu-9.10-desktop-i386.iso
- NS2版本:The Network Simulator - ns-2 (ns-allinone-2.34)
问题1
在安装NS2的过程中,可能会出现如下的错误信息:
- eneric/tk3d.c:242: error: ‘None’ undeclared (first use in this function)
- /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:243: error: ‘
-
- TkBorder’ has no member named ‘bgGC’
- /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:244: error: ‘
-
- TkBorder’ has no member named ‘darkGC’
- /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:245: error: ‘
-
- TkBorder’ has no member named ‘lightGC’
- /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:246: error: ‘
-
- TkBorder’ has no member named ‘hashPtr’
- ...........................................
- ...........................................
- eneric/tk3d.c:1400: error: ‘TkBorder’ has no member named ‘nextPtr’
- /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:1403: error:
-
- ‘TkBorder’ has no member named ‘resourceRefCount’
- /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:1405: error:
-
- ‘TkBorder’ has no member named ‘objRefCount’
- make: *** [tk3d.o] Error 1
- tk8.4.18 make failed! Exiting ...
eneric/tk3d.c:242: error: ‘None’ undeclared (first use in this function) /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:243: error: ‘ TkBorder’ has no member named ‘bgGC’ /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:244: error: ‘ TkBorder’ has no member named ‘darkGC’ /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:245: error: ‘ TkBorder’ has no member named ‘lightGC’ /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:246: error: ‘ TkBorder’ has no member named ‘hashPtr’ ........................................... ........................................... eneric/tk3d.c:1400: error: ‘TkBorder’ has no member named ‘nextPtr’ /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:1403: error: ‘TkBorder’ has no member named ‘resourceRefCount’ /media/Software/Quyettong/linux/soflware/ns2/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:1405: error: ‘TkBorder’ has no member named ‘objRefCount’ make: *** [tk3d.o] Error 1 tk8.4.18 make failed! Exiting ...
原因
The required packages are :
- libx11-dev , libxmu-dev , libxmu-headers , libxt-dev , libtool
libx11-dev , libxmu-dev , libxmu-headers , libxt-dev , libtool
参考:http://www.linuxquestions.org/questions/linux-newbie-8/ns-allinone-on-ubuntu-offline-765055/
解决方法
依次更新或者安装以上的程序包。完成后,执行"./install"
问题2
上面的问题解决好以后,可能会出现如下错误信息:
- No .configure file found in current directory
- Continuing with default options...
- checking build system type... i686-pc-linux-gnu
- checking host system type... i686-pc-linux-gnu
- checking target system type... i686-pc-linux-gnu
- checking for gcc... gcc
- checking for C compiler default output file name... a. out
- checking whether the C compiler works... yes
- checking whether we are cross compiling... no
- checking for suffix of executables...
- checking for suffix of object files... o
- checking whether we are using the GNU C compiler... yes
- checking whether gcc accepts -g... yes
- checking for gcc option to accept ISO C89... none needed
- checking for g++... g++
- checking whether we are using the GNU C++ compiler... yes
- checking whether g++ accepts -g... yes
- checking how to run the C preprocessor... gcc -E
- checking for grep that handles long lines and -e... /bin/grep
- checking for egrep... /bin/grep -E
- checking for ANSI C header files... yes
- checking for sys/types.h... yes
- checking for sys/stat.h... yes
- checking for stdlib.h... yes
- checking for string .h... yes
- checking for memory.h... yes
- checking for strings.h... yes
- checking for inttypes.h... yes
- checking for stdint.h... yes
- checking for unistd.h... yes
- checking for string .h... (cached) yes
- checking for main in -lXbsd... no
- checking for socket in -lsocket... no
- checking for gethostbyname in -lnsl... yes
- checking for dcgettext in -lintl... no
- checking for getnodebyname in -ldnet_stub... no
- checking that g++ can handle -O2... no
- checking standard STL is available... no
- checking for tcl.h... -I../include
- checking for tclInt.h... -I../include
- checking for libtcl8.4... -L../lib -ltcl8.4
- checking for init.tcl... ../lib/tcl8.4
- checking for http.tcl... ../lib/tcl8.4/http1.0
- checking Tcl http.tcl library... yes
- checking for tclsh8.4.18... no
- checking for tclsh8.4... ../bin/tclsh8.4
- checking for tk.h... -I../include
- checking for libtk8.4... -L../lib -ltk8.4
- checking for tk.tcl... ../lib/tk8.4
- checking for X11 header files
- checking for X11 library archive
- checking for XOpenDisplay in -lX11... yes
- checking for XShmAttach in -lXext... yes
- checking for ranlib... ranlib
- checking for a BSD-compatible install... /usr/bin/install -c
- checking system version (for dynamic loading)... Linux-2.6.31-14-generic
- No explicit static compilation flag; setting V_STATIC to ""
- checking for dlopen in -ldl... yes
- checking for a BSD-compatible install... /usr/bin/install -c
- configure: creating ./config.status
- config.status: creating Makefile
- rm -f libotcl.so otcl.o so_locations
- gcc -c -g -O2 -DNDEBUG -DUSE_SHM -fpic -I. -I/home /pengyicun/桌面/ns-allinone-2.34/include -
-
- I/home/pengyicun/桌面/ns-allinone-2.34/include -I/home /pengyicun/桌面/ns-allinone-2.34/include -I/include
-
- otcl.c
- ld -shared -o libotcl.so otcl.o
- otcl.o: In function `OTclDispatch':
- /home/pengyicun/桌面/ns-allinone-2.34/otcl-1.13 /otcl.c:495: undefined reference to `__stack_chk_fail_local'
- otcl.o: In function `Otcl_Init':
- /home/pengyicun/桌面/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' t defined
- ld: final link failed: Nonrepresentable section on output
- make: *** [libotcl.so] Error 1
- otcl-1.13 make failed! Exiting ...
No .configure file found in current directory Continuing with default options... checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for string.h... (cached) yes checking for main in -lXbsd... no checking for socket in -lsocket... no checking for gethostbyname in -lnsl... yes checking for dcgettext in -lintl... no checking for getnodebyname in -ldnet_stub... no checking that g++ can handle -O2... no checking standard STL is available... no checking for tcl.h... -I../include checking for tclInt.h... -I../include checking for libtcl8.4... -L../lib -ltcl8.4 checking for init.tcl... ../lib/tcl8.4 checking for http.tcl... ../lib/tcl8.4/http1.0 checking Tcl http.tcl library... yes checking for tclsh8.4.18... no checking for tclsh8.4... ../bin/tclsh8.4 checking for tk.h... -I../include checking for libtk8.4... -L../lib -ltk8.4 checking for tk.tcl... ../lib/tk8.4 checking for X11 header files checking for X11 library archive checking for XOpenDisplay in -lX11... yes checking for XShmAttach in -lXext... yes checking for ranlib... ranlib checking for a BSD-compatible install... /usr/bin/install -c checking system version (for dynamic loading)... Linux-2.6.31-14-generic No explicit static compilation flag; setting V_STATIC to "" checking for dlopen in -ldl... yes checking for a BSD-compatible install... /usr/bin/install -c configure: creating ./config.status config.status: creating Makefile rm -f libotcl.so otcl.o so_locations gcc -c -g -O2 -DNDEBUG -DUSE_SHM -fpic -I. -I/home/pengyicun/桌面/ns-allinone-2.34/include - I/home/pengyicun/桌面/ns-allinone-2.34/include -I/home/pengyicun/桌面/ns-allinone-2.34/include -I/include otcl.c ld -shared -o libotcl.so otcl.o otcl.o: In function `OTclDispatch': /home/pengyicun/桌面/ns-allinone-2.34/otcl-1.13/otcl.c:495: undefined reference to `__stack_chk_fail_local' otcl.o: In function `Otcl_Init': /home/pengyicun/桌面/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't defined ld: final link failed: Nonrepresentable section on output make: *** [libotcl.so] Error 1 otcl-1.13 make failed! Exiting ...
原因
gcc 4.0版本以前是用"ld -share"来生成共享库的,但是到了4.0以上的版本(我的为gcc version 4.4.1),这个命令改为"gcc -share"即可
解决方法
把ns-allinone-2.33/otcl-1.13文件夹下的configure.in及configure中的"ld -shared"替换成"gcc -shared",并保存。回到ns-allinone-2.33/目录重新运行"./install"
参考:http://blog.sina.com.cn/s/blog_4d1bbec70100gkjh.html
最后结果
安装过程时间持续比较长(大约20min),需要耐心等待,如果正确安装会出现如下信息:
- Ns-allinone package has been installed successfully.
- Here are the installation places:
- tcl8.4.18: /home/pengyicun/桌面/ns-allinone-2.34 /{bin,include,lib}
- tk8.4.18: /home /pengyicun/桌面/ns-allinone-2.34/{bin,include,lib}
- otcl: /home/pengyicun/桌面/ns-allinone-2.34/otcl-1.13
- tclcl: /home/pengyicun/桌面/ns-allinone-2.34/tclcl-1.19
- ns: /home/pengyicun/桌面/ns-allinone-2.34/ns-2.34/ns
- nam: /home/pengyicun/桌面/ns-allinone-2.34/nam-1.14/nam
- gt-itm: /home/pengyicun/桌面/ns-allinone-2.34 /itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns
-
- ----------------------------------------------------------------------------------
-
- Please put /home /pengyicun/桌面/ns-allinone-2.34/bin:/home/pengyicun/桌面/ns-allinone-
-
- 2.34/tcl8.4.18/unix: /home/pengyicun/桌面/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 /pengyicun/桌面/ns-allinone-2.34/otcl-1.13, /home/pengyicun/桌面/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 /pengyicun/桌面/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.