我的一个程序在qt designer中编译成功了,可以用,可是到了qte下面就出现了问题:我用到了求绝对值函数abs,所以包含了头文件math.h在.cpp前面就用了#include <math.h>,可是到了qte下面编译就说我`abs' undeclared (first use this function),我想知道是怎么回事?我要怎么修改呢?请帮我解答一下,谢谢!
math.h是math库,是C库,不属于标准C++。使用math库编译时还要加上-lm。
你首先要弄清楚你的qt designer和qte的编译环境(如编译器及版本,所附带的库)的区别,这样才能移植啊。
如果没有正确包含math.h。编译器应该会提示您
error: math.h: No such file or directory
正确。没有提示error: math.h: No such file or directory 说明已经包含了。
我查了一, man abs,abs在<stdlib.h>中定义,不需要math库。就是说C库自带了,不需要、#include <math.h>。
qte我不清楚,可能他的编译器是精简的,不包含abs。如果这样的话,你自己实现好了。