Vmware10+Ubuntu10.0.4下ns2-allinone-2.34安装方法
- 格式:doc
- 大小:41.00 KB
- 文档页数:6
Ubuntu11.04下安装ns-allinone-2.34的总结已有 2312 次阅读 2011-7-25 15:12 |个人分类:自学知识总结|系统分类:科研笔记|关键词:linux安装 windows 解决方案 color 网站安装ns-allinone-2.34的经历,让我深深感到学习WSN的难度。
由于对linux系统的恐惧,想在windows xp下安装ns-allinone-2.34,于是先安装了cygwin,然后安装ns-allinone-2.34时关键时刻总出错,网上对这种新版本的ns2的安装解决方案也没有,最后只能放弃,开始了linux安装之旅。
步骤一、安装linux系统之Ubuntu在网上能下载到Ubuntu 11.04/,据说是最容易和简单的linux系统,很欣慰,于是开始装。
同时在该网站上下载了wubi.exe,能帮助初装的人在windows下自动安装Ubuntu 11.04。
1、在电脑里整理出10G大小的磁盘空间,用以安装Ubuntu 11.04。
点击wubi.exe,出现自动安装的界面,设置好安装的磁盘位置,大小,以及用户名和密码等(这个很重要,也一定要记住),系统就会进入自动安装过程,要保持网络连接顺利。
2、上述过程结束后,电脑将重启,同时进入到windows和ubuntu两个系统界面选项,此时移动上下键,选择ubuntu,进入到ubuntu的自动安装界面。
整个过程,由于各种笨笨的操作失误,我持续了将近5个多小时,实际上2个小时就可以搞定。
不过我安装完后,很是兴奋,呵呵,第一次独立安装了 linux系统,没有高手指点,安装后的Ubuntu系统很是漂亮,与多年前我对linux系统的印象完全不一样。
记得五六年前,为了完成linux系统下嵌入式程序开发,研究过一些linux,对此深感恐惧和遗憾,那时的操作系统界面不是友好界面,什么都得靠指令,而且很多应用程序要经历诸多曲折才能安装在linux下。
1、下载地址:/wiki/index.php/Main_Page2、安装依赖软件包:$ sudo apt-get update$ sudo apt-get install build-essential$ sudo apt-get install tcl8.5 tcl8.5-dev tk8.5 tk8.5-dev$ sudo apt-get install libxmu-dev libxmu-headers3、存放路径:$HOME/Downloads$ cd $HOME/Downloads$ tar –zxvf ns-allinone-2.34.tar.gz$ mv ns-allinone-2.34 ns$ cd ns/$ sudo ./install4、安装可能存在的问题(源码修改):错误一:tools/: In member function ‘virtual double GammaRandomVariable::value()’: tools/:219:70: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directlytools/:219:70: error: for a function-style cast, remove the redundant ‘::GammaRandomVariable’make: *** [tools/ranvar.o]错误1Ns make failed!See /nsnam/ns/ns-problems.html for problems这是由于gcc版本提高后对类内部函数调用的简化造成的不兼容。
解决方法如下:在ns-allinone-2.34/ ns-2.34/tools文件夹下,找到报错提示中的文件,打开找到对应的219行删除::GaammaRandomVariable,保存,即:将219行的return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);改为: return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);错误二:mobile/: In member function ‘virtual double Nakagami::Pr(Pac ketStamp*, PacketStamp*, WirelessPhy*)’:mobile/:183:73: error: cannot call constructor ‘ErlangRandomVariable::ErlangRandomVariable’ directlymobile/:183:73: error: for a function-style cast, remove the redundant ‘::ErlangRandomVariable’mobile/:185:67: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directlymobile/:185:67: error: for a function-style cast, remove the redundant ‘::GammaRandomVariable’make: *** [mobile/nakagami.o]错误1Ns make failed!See /nsnam/ns/ns-problems.html for problems解决方法:在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的文件,打开找到对应的183行删除::ErlangRandomVariable,保存,即:将183行的resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();改为: resultPower = ErlangRandomVariable(Pr/m, int_m).value();在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的文件,打开找到对应的185行删除::GammaRandomVariable,保存,即:将185行的resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();改为: resultPower = GammaRandomVariable(m, Pr/m).value();错误三:mac/mac-802_11Ext.h: In member function ‘u_int32_tPHY_MIBExt::getHdrLen11()’:mac/mac-802_11Ext.h:176:19: error: expected primary-expression before ‘struct’mac/mac-802_11Ext.h:176:41: error: ‘dh_body’ was not declared in this scopemac/mac-802_11Ext.h:176:51: error: ‘offsetof’ was not declared in this scope解决方法:在ns-allinone-2.34\ns-2.34\mac\mac-802_11Ext.h 文件添加#include <cstddef> 问题四:mobile/: In member function ‘virtual doubleNakagami::Pr(PacketStamp*, PacketStamp*, WirelessPhy*)’:mobile/:183:73: error: cannot call constructor‘ErlangRandomVariable::ErlangRandomVariable’ directlymobile/:183:73: error: for a function-style cast, remove the redundant ‘::ErlangRandomVariable’mobile/:185:67: error: cannot call constructor‘GammaRandomVariable::GammaRandomVariable’ directlymobile/:185:67: error: for a function-style cast, remove the redundant ‘::GammaRandomVariable’解决方法:在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的文件,打开找到对应的183行删除::ErlangRandomVariable,保存,即:将183行的resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();改为:resultPower = ErlangRandomVariable(Pr/m, int_m).value();在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的文件,打开找到对应的185行删除::GammaRandomVariable,保存,即:将185行的resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();改为:resultPower = GammaRandomVariable(m, Pr/m).value();问题五:In file included from linkstate/:67:0:linkstate/ls.h: In instantiation of ‘void LsMap::eraseAll() [with Key = int; T = LsId Seq]’:linkstate/:396:28: required from herelinkstate/ls.h:137:20: error: ‘erase’ was not declared in this scope, and no declaratio ns were found by argument-dependent lookup at the point of instantiation [-fpermissive]linkstate/ls.h:137:20: note: declarations in dependent base ‘std::map, std::allocator > >’ are not found by unqualified lookuplinkstate/ls.h:137:20: note: use ‘this->erase’ insteadmake: *** [linkstate/ls.o] Error 1Ns make failed!解决方法:将 ns/ns-2.35/linkstate/ls.h中的137行void eraseAll() { erase(baseMap::begin(), baseMap::end()); }改为 void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }5、添加配置路径:在~/.bashrc文件中添加如下路径($ gedit ~/.bashrc):export NS_PATH=$HOME/Downloads/nsexportPATH=$PATH:$NS_PATH/bin:$NS_PATH/tcl8.4.18/unix:$NS_PATH/tcl8.4.18 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NS_PATH/otcl-1.13:$NS_PATH/libexport TCL_LIBRARY=$TCL_LIBRARY:$NS_PATH/tcl8.4.18/library6、测试方法一:ns成功方法二:$ cd $NS_PATH/ns-2.34/ 执行./validate。
ubuntu10.04ns2.34安装教程Ubuntu 10.04安装ns2-2.34因为Linux系统中即使你是管理员,当你需要在其上安装软件时也需要使用root权限。
所以第一步,需要开启root用户,并设置密码(ubuntu默认不开启root用户)命令:sudo passwd root这时会要求你输入你安装时设置的那个用户密码(验证身份),输入即可。
现在会要求你为root用户设置密码(需要输入两遍),因此总共需要输入三次密码,为了容易记住,建议密码设置一样。
当完成第一步后,可以使用下面的命令取得root权限(因为即将开始安装更新等一些软件,需要输入密码)命令:su1、在官方网站上下载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-headers4、进行安装我的是把ns-allinone-2.34.tar.gz压缩包放在/home/kenji自己的文件夹)下,输入如下命令解压:$ tar zxf ns-allinone-2.34.tar.gz运行安装命令:$ cd ns-allinone-2.34$ ./install然后就开始安装ns-allinone-2.34,大概过几分钟,在结束时候突然报错:ld -shared-o libotcl.so otcl.ootcl.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'tdefinedld: finallink failed: Nonrepresentable section on outputmake: ***[libotcl.so]错误1otcl-1.13make failed! Exiting ...See/doc/d914381145.html,/nsnam/ns /ns-problems.html forproblems分析错误原因:这是因为gcc版本高了,gcc 4.0以前的版本是用ld –share来生成共享库的,但是到了gcc 4.0以后的版本,这个命令就改成了gcc –share。
Ubuntu 11.04 安装 ns2-allinone-2.34【完整版】(附各种问题解决方案)这真是一个痛苦并快乐到过程,尝试多次安装,最终迎来来伟大的复兴!终于安装成功了!!!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 经验:先将本文提到的错误在./INSTALL之前全部改正后可减少出错机会1.首先,修改更新源,原有的更新源无法完成更新。
以下是ubuntu 11.04 教育网的源:sudo gedit /etc/apt/sources.list#网易资源deb /ubuntu/ natty main restricted universe multiversedeb /ubuntu/ natty-security main restricted universe multiversedeb /ubuntu/ natty-updates main restricted universe multiversedeb /ubuntu/ natty-proposed main restricted universe multiversedeb /ubuntu/ natty-backports main restricted universe multiversedeb-src /ubuntu/ natty main restricted universe multiverse deb-src /ubuntu/ natty-security main restricted universe multiversedeb-src /ubuntu/ natty-updates main restricted universe multiversedeb-src /ubuntu/ natty-proposed main restricted universe multiversedeb-src /ubuntu/ natty-backports main restricted universe multiverse2、更新Ubuntu系统文件,虽然系统是最新版本的,但是不代表里面的文件都是最新的,需要更新。
WIN7 64位下装NS-2(Ubuntu 10.10+ns-allinone-2.34.tar.gz)1.首先下载安装VMWARE虚拟机并进行安装虚拟机。
2.在虚拟机下安装Ubuntu 10.10.3.下载Nns-allinone-2.34.tar.gz。
由于在Ubuntu linux下不能自动加载优盘,所有需要将ns-allinone-2.34.tar.gz拷贝到linux下的home目录中时,需要先对优盘进行加载,加载的命令为:cd /mediasudo mkdir usbsudo mount /dev/sdb1 ./usbcd usbLs通过ls显示后就可以看到加载的U盘内容。
经过以上命令后,目录应该是在usb下,所有直接利用cp命令将ns-allinone-2.34.tar.gz拷贝到home目录下sudo cp ns-allinone-2.34.tar.gz /home。
4.在安装ns-allinone-2.34.tar.gz之前,需要先下载安装一些包,返回到根目录下输入命令:sudo apt-ge install build-essentialsudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-devsudo apt-get install libxmu-dev libxmu-hedaers5.安装完必须的包后,输入cd /home进入home目录下进行安装ns-allinone-2.34.tar.gz,输入命令sudo xvfz ns-allinone-2.34.tar.gz //解压缩sudo cd ns-allinone-2.34sudo ./install输入命令后系统会进行安装。
6.配置环境变量在所用的Ubuntu 10.10中由于不能使用sudo gedit .bashrc对.bashrc进行打开编辑,所有采用了nano对.bashrc进行编辑。
NS2安装步骤与注意事项一、NS2是运行在linux系统环境中的,故其安装主要分三步:装虚拟机,在虚拟机上装ubuntu,在ubuntu上装NS2。
二、虚拟机安装,VMware-workstation-full-7.1.4-385536.7z。
跟装其他软件一样,无需特殊设置。
Win7系统下,用较新版本的虚拟机,旧版本上网设置太麻烦。
三、在虚拟机上安装linux系统。
打开VMware workstation,创建一个新的虚拟机,根据安装向导,typical典型安装,next,注意选I will install the operating system later(稍后安装操作系统),之后选择自己的操作系统版本及安装位置,磁盘容量自选,安装完成。
(一)、最开始安装的是redhat版本的linux:我的redhat的系统是三个光盘映像文件,打开VMware workstation左边的Sidebar有显示自己刚才安装的虚拟机,Red Hat Linux。
1、设置操作系统的安装是从光盘映像文件启动:VM→settings→CD/DVD(IDE),右边栏里connection选择use ISO image file(使用光盘映像文件),定位到第一个光盘映像。
OK之后启动redhat,开始安装。
2、第一张光盘安装完成会提示插入第二张光盘。
同样从VM→settings→CD/DVD(IDE)定位到第二张光盘,OK 之后不会继续安装。
注意此处在点OK之前需要将上边Device status 下的connected打上对勾,(默认的只有第二个有对勾),这样点OK才能继续安装第二张光盘,同理安装第三张光盘。
Redhat里边插入U盘不能直接识别,先将U盘挂载,U盘里的安装包拷到Redhat内,再安装,安装各种出错……o(╯□╰)o Redhat版本的linux系统操作不方便,换用ubuntu。
可以考虑在redhat 上再装一个ns2.(二)ubuntu安装Ubuntu操作系统只有一个光盘映像文件。
ubuntu下双网卡配置一需求说明OMAP的开发板上有两个网口,需要这个两个网口工作在不同的网段,可以同时并发运行。
二环境说明1 交叉网线将开发板网口eth0和笔记本电脑连接2 直连网线将开发板网口eth1和路由器相连3 路由器是在192.168.1.*网段三系统文件配置1 笔记本配置root@xxy-pc:/etc# cd /etc/networkroot@xxy-pc:/etc/network# vim interfaces添加下列内容auto eth0iface eth0 inet staticaddress 192.168.0.1netmask 255.255.255.02 OMAP开发板配置以下都是在开发板的调试串口输出中输入命令:vim /etc/network/interfaces添加如下内容:auto loiface lo inet loopback#auto eth0#iface eth0 inet dhcpauto eth1iface eth1 inet staticaddress 192.168.1.150netmask 255.255.255.0network 192.168.1.1broadcask 192.168.1.255 gateway 192.168.1.1auto eth0iface eth0 inet staticaddress 192.168.0.151netmask 255.255.255.0network 192.168.0.1broadcask 192.168.0.1gateway 192.168.0.1输入命令:vim /etc/resolv.conf nameserver 192.168.1.1nameservre 192.168.0.1nameservre 8.8.8.8四测试说明:1 在笔记本电脑的终端中输入命令ping 192.168.0.151终端输出为说明eth0工作正常2 在开发板的调试串口输入命令ping 192.168.1.1终端输出为说明eth1工作正常。
Ubuntu安装NS2中出现问题.在新立得软件包管理器中下载最新的NS2.34,下载结束后解压安装(我解压在根目录中)$ tar -xzvf ns-allinone-2.34.tar.gz$ cd ns-allinone-2.34$./install*注意当出现类似tk8.4.18,安装中断退出时,先输入:sudo apt-cache search x11-dev得到类似以下信息:libgl1-mesa-swx11-dev - A free implementation of the OpenGL API -- development fileslibx11-dev - X11 client-side library (development headers)libghc6-x11-dev - Haskell X11 binding for GHClibgtkglextmm-x11-dev - C++ wrapper for the OpenGL Extension to GTK (development files)分别安装上面的组件(更新为最新版本,当然如果已经是最新版本的话,它会提醒),命令如下:sudo apt-get install libx11-devsudo apt-get install libgl1-mesa-swx11-devsudo apt-get install libghc6-x11-devsudo apt-get install libgtkglextmm-x11-dev问题一:刚开始安装时显示gcc can't create executables之类的提示解决方案:这是由于我用的是Ubuntu免费邮寄的安装盘,安装后的系统中gcc是不能用来的开发的,只有一个空壳,所以需要重新安装gcc。
先用命令:sudo apt-get remove gcc然后sudo apt -get install build-essential 便成功解决问题。
Ubuntu10相关网络问题解决方案一、使用命令设置ubuntu的ip地址1. 设置IPsudo ifconfig eth0 203.171.239.155 netmask 255.255.255.224这样就算设置好了网卡eth0的IP地址和子网掩码2. 设置网关 sudo route add default gw 203.171.239.1293. 设置DNS 修改/etc/resolv.conf,在其中加入nameserver DNS的地址1 nameserver DNS的地址2 完成。
不过,这样设置之后,下次开机时候似乎IP又不存在了。
二、直接修改系统配置文件ubuntu的网络配置文件是:/etc/network/interfacesubuntu命令行修改网络配置方法/etc/network/interfaces打开后里面可设置DHCP或手动设置静态ip。
前面auto eth0,让网卡开机自动挂载.1. 以DHCP方式配置网卡编辑文件/etc/network/interfaces:sudo vi /etc/network/interfaces并用下面的行来替换有关eth0的行:# The primary network interface - use DHCP to find our addressauto eth0iface eth0 inet dhcp用下面的命令使网络设置生效:sudo /etc/init.d/networking restart也可以在命令行下直接输入下面的命令来获取地址sudo dhclient eth02. 为网卡配置静态IP地址编辑文件/etc/network/interfaces:sudo vi /etc/network/interfaces并用下面的行来替换有关eth0的行:# The primary network interfaceauto eth0iface eth0 inet staticaddress 192.168.3.90gateway 192.168.3.1netmask 255.255.255.0#network 192.168.3.0#broadcast 192.168.3.255将上面的ip地址等信息换成你自己就可以了.用下面的命令使网络设置生效:sudo /etc/init.d/networking restart3. 设定第二个IP地址(虚拟IP地址)编辑文件/etc/network/interfaces:sudo vi /etc/network/interfaces在该文件中添加如下的行:auto eth0:1iface eth0:1 inet staticaddress 192.168.1.60netmask 255.255.255.0network x.x.x.xbroadcast x.x.x.xgateway x.x.x.x根据你的情况填上所有诸如address,netmask,network,broadcast和gateways等信息.用下面的命令使网络设置生效:sudo /etc/init.d/networking restart4. 设置主机名称(hostname)使用下面的命令来查看当前主机的主机名称:sudo /bin/hostname使用下面的命令来设置当前主机的主机名称:sudo /bin/hostname newname系统启动时,它会从/etc/hostname来读取主机的名称.关于设置主机名称的更多信息,请访问这里5. 配置DNS首先,你可以在/etc/hosts中加入一些主机名称和这些主机名称对应的IP地址,这是简单使用本机的静态查询.要访问DNS 服务器来进行查询,需要设置/etc/resolv.conf文件.假设DNS服务器的IP地址是192.168.3.2, 那么/etc/resolv.conf 文件的内容应为:search nameserver 192.168.3.26.手动重启网络服务:sudo /etc/init.d/networking restart返回结果如下:*Reconfiguring network interfaces… [OK]现在,你可以在终端里输入ipconfig命令来查看你修改的结果。
[ubuntu10.4 Linux环境配置] (2)1. VI功能增强 (2)1.1 VI中不能正确使用上下箭头解决方法 (2)1.2.ubuntu里面颜色VI的个性设置 (2)2.安装SSH (3)3.启用root密码 (3)4.安装FTP服务 (4)5.配置samba (4)5.1,实验准备 (4)5.2. samba的安装 (5)5.3. 创建Samba配置文件 (5)5.4. 创建samba帐户 (6)5.5. 重启samba服务器 (6)5.6. 测试 (6)6. 安装vmware tools(适应于虚拟机上安装linux) (6)7.安装NFS服务器 (9)7.2 测试NFS (11)8.安装DHCP服务 (11)9.1 TFTP服务的设置 (12)9.2 TFTP服务测试 (13)10. 让Ubuntu Linux操作系统开启Telnet服务 (13)11.开发环境的安装 (16)11.1.安装工具链 (16)11.2 添加库函数手册 (17)12.安装和卸载Deb包 (17)FAQ (17)1.Ubuntu系统安装后添加的用户在用sudo的时候出现xxx is not in the sudoers file的解决方法 (17)[ubuntu10.4 Linux环境配置]1. VI功能增强1.1 VI中不能正确使用上下箭头解决方法sudo apt-get install vim-full (安装完整版本的VI)root@ubuntun1:/usr/bin# ls -al /usr/bin/vi (查看目前缺省的VI程序)lrwxrwxrwx 1 root root 20 Jan 21 01:15 vi -> /etc/alternatives/viroot@ubuntun1:/usr/bin# sudo ln -sf /usr/bin/vim.full /usr/bin/vi(适应于ubuntu7.10)root@ubuntun1:/usr/bin# sudo ln -sf /usr/bin/vim /usr/bin/vi(适应于ubuntu8.10,9.10,10.4)1.2.ubuntu里面颜色VI的个性设置新建 /etc/vim/vimrc.local,里面添加内容如下(仅供参考):set nuset nocpset ruset hlsset issyntax onset backspace=indent,eol,startset sw=4set ts=4set smset cincolo slateset guifont=Courier\ New\ 10map <F3> !g++ % -o mainutocmd FileType python setlocal et sta sw=4 sts=4Vi对中文的支持:新建用户目录下的 .vimrc$ vi ~/.vimrc添加如下内容:let &termencoding=&encodingset fileencodings=utf-8,gbk,ucs-bom,cp936在vi的命令行模式下输入 :wq! 保存退出。
Vmware10+Ubuntu10.0.4下ns2-allinone-2.34安装方法2014-3-28以下的安装经过本人验证,完全成功!首先下载到ns-allinone-2.34.tar.gz,这个网上到处都是。
然后开始在终端里输入命令,获取ns2需要的相关软件:sudo apt-get install build-essentialsudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-devsudo apt-get install libxmu-dev libxmu-headerssudo apt-get install xorg-dev g++ xgraphsudo apt-get install g++-4.4===============================然后解压ns-allinone-2.34.tar.gz,放到你指定的目录。
检查你的gcc版本,如果gcc版本大于4.0(大部分人的都是,建议直接改),要在执行./install之前作出一些修改。
gcc4.0版本以前是用ld-share来生成共享库的,但是到了4.0以上的版本,这个命令改为了gcc-share。
修改命令如下:cdns-allinone-2.34/otcl-1.13sudogedit configure.in把77行处的SHLIB_LD="ld-shared"改为SHLIB_LD="gcc-shared"保存退出,然后sudogedit configure把6304行(Ctrl+i跳到6304行)的SHLIB_LD="ld-shared"改为SHLIB_LD="gcc-shared"保存退出,然后cdns-allinone-2.34 #到安装目录sudo./install #开始安装如果没有更改直接安装,就会出现这样的错误:ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined ld: final link failed: Bad valuemake: *** [libotcl.so] Error 1这只是有可能出现的第一个错误,接下来还有更多的错误等着你!(所以要整理出这么一份东西来。
)===================================================================== ==================错误一:安装NS2.34过程中出现如下的错误:tools/: In member function ‘virtual double GammaRandomVariable::value()’:tools/:219:70: error: cannot call constructor‘GammaRandomVariable::GammaRandomVariable’ directlytools/:219:70: error: for a function-style cast, remove the redundant ‘::GammaRandomVariable’make: *** [tools/ranvar.o]错误1Ns make failed!See /nsnam/ns/ns-problems.html for problems这是由于gcc版本提高后对类内部函数调用的简化造成的不兼容,解决方法如下:在ns-allinone-2.34/ ns-2.34/tools文件夹下,找到报错提示中的 文件,打开找到对应的219行删除::GaammaRandomVariable,保存,即:将219行的return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_,beta_).value() * pow (u, 1.0 / alpha_);改为:return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);然后保存退出,重新安装ns2.===================================================================== =================错误二:In file included from mac/mac-802_:66:0:mac/mac-802_11Ext.h: In member function ‘u_int32_tPHY_MIBExt::getHdrLen11()’:mac/mac-802_11Ext.h:175:19: error: expected primary-expression before ‘struct’mac/mac-802_11Ext.h:175:41: error: ‘dh_body’ was not declared in this scopemac/mac-802_11Ext.h:175:51: error: ‘offsetof’ was not declared in this scopemac/mac-802_11Ext.h:177:3: warning: control reaches end of non-void function[-Wreturn-type]make: *** [mac/mac-802_11Ext.o] Error 1Ns make failed!下面是网上找得关于本问题的解决方案:If you get error like:mac/mac-802_11Ext.h: In member function ‘u_int32_tPHY_MIBExt::getHdrLen11()’:mac/mac-802_11Ext.h:176:19: error: expected primary-expression before ‘struct’mac/mac-802_11Ext.h:176:41: error: ‘dh_body’ was not d eclared in this scopemac/mac-802_11Ext.h:176:51: error: ‘offsetof’ was not declared in this scopeopen that file and add#include <cstddef>to the header files.在ns-allinone-2.34\ns-2.34\mac\mac-802_11Ext.h 文件添加#include<cstddef>然后重新安装,就OK了。
===================================================================== ========错误三:mobile/: In member function ‘virtual doubleNakagami::Pr(PacketStamp*, PacketStamp*, WirelessPhy*)’:mobile/:183:73: error: cannot call constructor‘ErlangRandomVariable::ErlangRandomVariable’ directlymobile/:183:73: error: for a function-style cast, remove the redundant ‘::ErlangRandomVariable’mobile/:185:67: error: cannot call constructor‘GammaRandomVariable::GammaRandomVariable’ direc tlymobile/:185:67: error: for a function-style cast, remove the redundant ‘::GammaRandomVariable’make: *** [mobile/nakagami.o]错误1Ns make failed!See /nsnam/ns/ns-problems.html for problems解决方法:在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的文件,打开找到对应的183行删除::ErlangRandomVariable,保存,即:将183行的resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m,int_m).value();改为:resultPower = ErlangRandomVariable(Pr/m, int_m).value();在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的文件,打开找到对应的185行删除::GammaRandomVariable,保存,即:将185行的resultPower = GammaRandomVariable::GammaRandomVariable(m,Pr/m).value();改为:resultPower = GammaRandomVariable(m, Pr/m).value();重新在ns目录下键入$ ./install安装,再次出现同类问题时,仿照此次解决方法,找到对应的文件和行数,修改即可。
直到安装成功。
===================================================================== ==================到这里安装终于成功了,不要忘记添加环境变量在/home目录下sudo gedit .bashrc在弹出的窗口文件最后输入exportPATH=$PATH:/home/yourfile/ns-allinone-2.34/bin:/home/yourfile/ns-all inone-2.34/tcl8.4.18/unix:/home/yourfile/ns-allinone-2.34/tk8.4.18/u nixexportLD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/yourfile/ns-allinone-2.34/otc l-1.13:/home/yourfile/ns-allinone-2.34/libexportTCL_LIBRARY=$TCL_LIBRARY:/home/yourfile/ns-alllinone-2.34/tcl8.4.18/ library============================验证(测试)(1)打开一个新的终端(2)输入ns并回车$ns (如果正常,会出现"%"操作提示符,如果显示还没有安装ns2,可以先安装nam,再测试ns)(3)输入一段测试用的Tcl脚本代码进行测试%puts "Hello World" (输出Hello World字符串)Hello World (如果正确,会显示Hello World)% (然后跳到下一个"%"提示符等待下一条指令输入)============================安装namcd ns-allinone-2.34/nam-1.14./configuremakesudo make install (至此,nam安装好)在终端中输入nam命令,弹出nam界面则说明nam安装好了到此ns2终于安装好!!如果遇到其他安装过程中的问题还会继续更新本文。