ns2安装错误三

原文:http://share.dzjs.net/down/2012/0425/file_24935.html

NS2安装过程总结,详解介绍在ubuntu下安装过程以及遇到问题解决方法,希望对大家有帮助
安装过程:
1.挂载:设置>数据空间>右击临时分配>添加要挂载的文件夹>打开终端>执行:$sudo mount –t vbossf adhoc /mnt 在ubuntu文件系统中找到mnt文件夹,将挂载的ns2压缩包复制到主文件夹中。
2.解压:终端执行:$tar -xzvf ns-allinone-2.34.tar.gz
3. 安装必须的软件环境:首先确定电脑网络连通>进入ns文件夹,终端依次执行: $cd ns-allinone-2.34 $sudo apt-get install build-essential autoconf automake libxmu-dev $sudo apt-get remove host
4.修改:进入otcl-1.13文件夹,打开文件configure,找到: Linux*) SHLIB_CFLAGS="-fpic" SHLIB_LD="ld -shared" SHLIB_SUFFIX=".so" DL_LIBS="-ldl" SHLD_FLAGS="" 将configure中“SHLIB_LD="ld -shared"一句改为SHLIB_LD="gcc -shared"
5.安装:$cd ns-allinone-2.34 $sudo ./install
1. 错误一: tools/ranvar.cc: In member function ‘virtual double GammaRandomVariable::value()’: tools/ranvar.cc:219:70: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly tools/ranvar.cc:219:70: error: for a function-style cast, remove the redundant ‘::GammaRandomVariable’ make: *** [tools/ranvar.o]错误1 Ns make failed! See http://www.isi.edu/nsnam/ns/ns-problems.html for problems
解 决办法: 在ns-allinone-2.34/ ns-2.34/tools文件夹下,找到报错提示中的ranvar.cc文件,打开找到对应的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。
2.错误二: In file included from mac/mac-802_11Ext.cc:66:0: mac/mac-802_11Ext.h: 在成员函数‘u_int32_t PHY_MIBExt::getHdrLen11()’中: mac/mac-802_11Ext.h:175:19: 错误: expected primary-expression before ‘struct’ mac/mac-802_11Ext.h:175:41: 错误: ‘dh_body’在此作用域中尚未声明 mac/mac-802_11Ext.h:175:51: 错误: ‘offsetof’在此作用域中尚未声明 mac/mac-802_11Ext.h:177:3: 警告: 在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
解决办法: 在ns-allinone-2.34 s-2.34\mac\mac-802_11Ext.h 文件添加#include <cstddef>然后重新安装,就OK了。
3.错误三: mobile/nakagami.cc: 在成员函数‘virtual double Nakagami::Pr(PacketStamp*, PacketStamp*, WirelessPhy*)’中: mobile/nakagami.cc:185:67: 错误: 不能直接调用构造函数‘GammaRandomVariable::GammaRandomVariable’ [-fpermissive] mobile/nakagami.cc:185:67: 错误: 对于函数类型的类型转换,移除冗余的‘::GammaRandomVariable’ [-fpermissive]
解决办法: 在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的nakagami.cc文件,打开找到对应的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文件夹下,找到报错提示中的nakagami.cc文件,打开找到对应的185行删除::GammaRandomVariable,保存, 即:将185行的 resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value(); 改为: resultPower = GammaRandomVariable(m, Pr/m).value(); 重新在ns目录下键入$ ./install安装,再次出现同类问题时,仿照此次解决方法,找到对应的文件和行数,修改即可。直到安装成功。 安装成功提示(还没结束!): Please put /home/haoliming/ns-allinone-2.34/bin:/home/haoliming/ns-allinone-2.34/tcl8.4.18/unix:/home/haoliming/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/haoliming/ns-allinone-2.34/otcl-1.13, /home/haoliming/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/haoliming/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. 按照提示要求: 更改启动环境变量,执行指令:$sudo gedit ~/.bashrc 在文件最后添加以下文本(若文件最后已经存在则不用添加): PATH="$PATH:/home/hq/ns-allinone-2.34/bin:/home/hq/ns-allinone-2.34/tcl8.5.10/unix:/home/hq/ns-allinone-2.34/tk8.5.10/unix"
LD_LIBRARY_PATH="/home/hq/ns-allinone-2.34/otcl-1.14, /home/hq/ns-allinone-2.34/lib" TCL_LIBRARY="$TCL_LIBRARY:/home/hq/ns-allinone-2.34/tcl8.5.10/library" 注意:以上三行中将hq用你的系统ns-allinone-2.34所在文件夹名称替换掉,保存退出后执行指令:$ source ~/.bashrc 验证:执行:$ ns 回车后若出现%则安装成功。

posted @ 2012-09-24 11:21  xiaolongxia  阅读(402)  评论(0)    收藏  举报