一直使用windows系统 + cygwin + ns2 2.34
最近入手Macbook pro一小台,本来试图安装win7,然后继续的,结果屡次不成功,某学术男提示说,你为什么不在mac系统上安装呢,那个也是unix系列的系统。于是便开始了尝试,一共两天吧,最终算是成功了,现在写下安装过程~
Step1. 下载xcode (http://developer.apple.com/technologies/tools/xcode.html) 直接安装就可以,会安装到一个叫做/Developer的文件夹下面,然后寻找/Developer/SDKs/MacOSX10.6.sdk/X11R6/lib目录下有很多文件,就是后来要用的。(reference:http://lovefei.com/?p=86)
Step2. 下载ns2 2.33 allinone package (http://sourceforge.net/projects/nsnam/files/),进入mac的terminal使用tar zxvf ns-allinone-2.33.tar.gz 来解压缩。
Step3. 最关键的一步,需要手动修改ns-allinone-2.33目录下面的install文件,右键(control+单击)打开方式选择xcode, 然后修改如下:(reference:http://old.nabble.com/Installation-on-OSX-10.6-td27790838.html)
#! /bin/sh
#
# Copyright (C) 2000 by USC/ISI
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation, advertising
# materials, and other materials related to such distribution and use
# acknowledge that the software was developed by the University of
# Southern California, Information Sciences Institute. The name of the
# University may not be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# $Header: /cvsroot/nsnam/ns-2/allinone/install,v 1.31 2007/03/10 23:40:05 tom_henderson Exp $
X_INCL = /Developer/SDKs/MacOSX10.6.sdk/usr/X11R6/include
X_LIBS = /Developer/SDKs/MacOSX10.6.sdk/usr/X11R6/lib
MACOS_CONF = "--x-include=$X_INCL --x-libraries=$X_LIBS"
die() {
echo "$@" 1>&2
test ! -z "$blame" && echo "$blame" 1>&2
exit 1
}
warn() {
echo "$@"
}
。。。
。。。
# Build otcl
echo "============================================================"
echo "* Build OTcl-$OTCLVER"
echo "============================================================"
cd ./otcl-$OTCLVER
blame='Please check http://www.isi.edu/nsnam/ns/ns-problems.html
for common problems and bug fixes.'
if [ "${test_cygwin}" = "true" ]; then
./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include || die "otcl-$OTCLVER configuration failed! Exiting ...";
else
./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include CFLAGS="-framework CoreFoundation" || die "otcl-$OTCLVER configuration failed! Exiting ...";
fi
if make
then
echo "otcl-$OTCLVER has been installed successfully."
else
echo "otcl-$OTCLVER make failed! Exiting ..."
echo "See http://www.isi.edu/nsnam/ns/ns-problems.html for problems"
exit
fi
cd ..
# Build tclcl
echo "============================================================"
echo "* Build Tclcl-$TCLCLVER"
echo "============================================================"
cd ./tclcl-$TCLCLVER
if [ "${test_cygwin}" = "true" ]; then
./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include || die "tclcl-$TCLCLVER configuration failed! Exiting ...";
else
./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include --with-otcl=../otcl-$OTCLVER || die "tclcl-$TCLCLVER configuration failed! Exiting ..."
fi
if make
then
echo "tclcl-$TCLCLVER has been installed successfully."
else
echo "tclcl-$TCLCLVER make failed! Exiting ..."
echo "See http://www.isi.edu/nsnam/ns/ns-problems.html for problems"
exit
fi
cd ../
# John's hack
test -f ./otcl-$OTCLVER/libotcl.a && rm ./otcl-$OTCLVER/libotcl.so
echo "============================================================"
echo "* Build ns-$NSVER"
echo "============================================================"
cd ./ns-$NSVER
if [ -f Makefile ] ; then
make distclean
fi
if [ "${test_cygwin}" = "true" ]; then
./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include || die "Ns configuration failed! Exiting ...";
else
./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include LIBS="-framework CoreFoundation" --with-otcl=../otcl-$OTCLVER --with-tclcl=../tclcl-$TCLCLVER || die "Ns configuration failed! Exiting ...";
fi
if make
then
echo " Ns has been installed successfully."
else
echo "Ns make failed!"
echo "See http://www.isi.edu/nsnam/ns/ns-problems.html for problems"
exit
fi
cd ../
# Build nam
echo "============================================================"
echo "* Build nam-$NAMVER"
echo "============================================================"
ln -s otcl-$OTCLVER otcl
ln -s tclcl-$TCLCLVER tclcl
cd ./nam-$NAMVER
# XXX temporary OS X hack
if [ "${test_darwin}" = "true" ]; then
ln -s /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation libcorefoundation.dylib
fi
if [ "${test_cygwin}" = "true" ]; then
./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include --with-tclcl=$CUR_PATH/tclcl-$TCLCLVER || die "Nam configuration failed! Exiting ...";
else
./configure --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include V_LIBS="-framework CoreFoundation" --with-otcl=../otcl-$OTCLVER --with-tclcl=../tclcl-$TCLCLVER || die "Nam configuration failed! Exiting ...";
fi
Step4. 之后cd ns-allinone-2.33运行./install即可。
Step5. 修改环境变量
1)echo "PATH=/Users/username/ns2/ns-allinone-2.31/bin:$PATH" > .bashrc (reference:http://sites.google.com/site/pengjungwu/install-ns2-31-on-osx)
2)(http://lovefei.com/?p=86) 5.1 input “echo $SHELL” and you can see if it is “bash“, which means Bourne Shell. (os X after 10.3 is using Bourne Shell by default)
5.2 modify .profile or .bash_profile at home, add the related variables like this:
export PATH=$PATH:/Users/wangxiaofei/work/ns/229/bin:/Users/wangxiaofei/work/ns229/tcl8.4.11/unix:/Users/wangxiaofei/work/ns/229/tk8.4.11/unix
export LD_LIBRARY_PATH=/Users/wangxiaofei/work/ns/229/otcl-1.11:/Users/wangxiaofei/work/ns/229/lib
export TCL_LIBRARY=/Users/wangxiaofei/work/ns/229/tcl8.4.11/library
5.3 input “source .profile“, you can run ns2 well now!~~~ ^^