threshold工具编译问题解决方法

threshold是NS2自带的一个用来计算不同的无线传输模型和传输矩离下的相关参数的小工具.

用法如下 :

root@ubuntu:~/ns-allinone-2.34/ns-2.34/indep-utils/propagation$ ./threshold
USAGE: find receiving threshold for certain communication range (distance)

SYNOPSIS: threshold -m <propagation-model> [other-options] distance

<propagation-model>: FreeSpace, TwoRayGround or Shadowing        //三种传输模型
[other-options]: set parameters other than default values:                   //以下参数均可自行配置

Common parameters:
-Pt <transmit-power>
-fr <frequency>
-Gt <transmit-antenna-gain>
-Gr <receive-antenna-gain>
-L <system-loss>

For two-ray ground model:
-ht <transmit-antenna-height>
-hr <receive-antenna-height>

For shadowing model:
-pl <path-loss-exponent>
-std <shadowing-deviation>
-d0 <reference-distance>
-r <receiving-rate>


该程序的是用C++编写的,位于NS2文件夹下的 ns-allinone-2.34/ns-2.34/indep-utils/propagation/.
程序源码需要编译才能运行:
$g++ -lm threshold.cc -o threshold
然而本人在编译时出现问题:
root@ubuntu:~/ns-allinone-2.34/ns-2.34/indep-utils/propagation$ g++ -lm threshold.cc -o threshold
threshold.cc:56:22: error: iostream.h: 没有那个文件或目录
threshold.cc: In function ‘int main(int, char**)’:
threshold.cc:181: error: ‘cout’ was not declared in this scope
threshold.cc:181: error: ‘endl’ was not declared in this scope
threshold.cc:206: error: ‘cout’ was not declared in this scope
threshold.cc:206: error: ‘endl’ was not declared in this scope
threshold.cc:211: error: ‘strcmp’ was not declared in this scope
threshold.cc:215: error: ‘strcmp’ was not declared in this scope
threshold.cc:218: error: ‘strcmp’ was not declared in this scope
threshold.cc:221: error: ‘strcmp’ was not declared in this scope
threshold.cc:224: error: ‘strcmp’ was not declared in this scope
threshold.cc:227: error: ‘strcmp’ was not declared in this scope
threshold.cc:230: error: ‘strcmp’ was not declared in this scope
threshold.cc:233: error: ‘strcmp’ was not declared in this scope
threshold.cc:236: error: ‘strcmp’ was not declared in this scope
threshold.cc:239: error: ‘strcmp’ was not declared in this scope
threshold.cc:242: error: ‘strcmp’ was not declared in this scope
threshold.cc:245: error: ‘strcmp’ was not declared in this scope
threshold.cc:259: error: ‘strcmp’ was not declared in this scope
        

排查问题发现,threshold.cc源文件中缺少相关头文件,或者头文件错误,原文如下:

#include <math.h>
#include <stdlib.h>

修改成如下就可以正常编译了:

#include <math.h>
#include <stdlib.h>
#include <iostream>    //增加该头文件以引用输出函数
#include <string.h>      //增加该头文件以引用'strcmp'函数
using namespace std;
  //增加命名空间的声明
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值