施用数学函数pow时出现:undefined reference to `pow'
使用数学函数pow时出现:undefined reference to `pow环境是Ubuntu 12.04我已经#include math.h, 编译时
使用数学函数pow时出现:undefined reference to `pow'
环境是Ubuntu 12.04
我已经#include <math.h>, 编译时也加上了 -lm,但还是出现题目中的错误:
CWTNM.c:(.text+0x2ed0): undefined reference to `pow'
CWTNM.c:(.text+0x2ef5): undefined reference to `pow'
collect2: ld returned 1 exit status
下面是代码:
C/C++ codepen_score[var] = pow(4.0, clause_weight[var]);
clause_weight[var]是Int, pen_score[var]是double。
貌似出现的问题跟这些类型完全没关系, 因为根本就undefine了。
[解决办法]用#include <cmath>这个试下
[解决办法]亲自打开math.h文件看一下里面有没有pow函数。
[解决办法]powf
[解决办法] #include <math.h>
double pow(double x, double y);
float powf(float x, float y);
long double powl(long double x, long double y);
Link with -lm.