警告:内置函数的不兼容隐式声明' lrint'

时间:2015-07-29 17:27:02

标签: c opencv

我想在Linux机器上编译一个opencv程序:

sav@machine:/shared/sav/test$ uname -a
Linux machine 2.6.32-24-generic #43-Ubuntu SMP Thu Sep 16 14:58:24 UTC 2010 x86_64 GNU/Linux

我的gcc命令如下:

gcc -I/shared/sav/opt/include -L/shared/sav/opt/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lm imagefilter.c -o imagefilter

运行程序后,我收到以下警告:

In file included from /shared/sav/opt/include/opencv2/core/core_c.h:47,
from /shared/sav/opt/include/opencv/cv.h:63,
from imagefilter.c:1:
/shared/sav/opt/include/opencv2/core/types_c.h: In function 'cvRound':
/shared/sav/opt/include/opencv2/core/types_c.h:327: warning: incompatible implicit declaration of built-in function 'lrint'

如何修复此警告?

2 个答案:

答案 0 :(得分:1)

  1. 首先确保您已在程序中包含标题math.h
  2. 使用此-std=c99选项和gcc来解决此编译器问题。
  3. 更改

    gcc -I/shared/sav/opt/include -L/shared/sav/opt/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lm imagefilter.c -o imagefilter 
    

    gcc -std=c99 -I/shared/sav/opt/include -L/shared/sav/opt/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lm imagefilter.c -o imagefilter
    

    有关lrint

    的使用的详情,请参阅此处

答案 1 :(得分:0)

包括以下头文件(math.h)。通常这个警告是因为不包括定义函数的头文件。

#include <math.h>