Opencv: Undefined reference to cvRound in opencv 3.2

Created on 23 Mar 2017  路  3Comments  路  Source: opencv/opencv

System information (version)
  • OpenCV => 3.2
  • Operating System / Platform => linux Ubuntu 16.04 64 Bit
  • Compiler => gcc
Detailed description

I have recently installed opencv 3.2 in ubuntu 16.04 system and tried to run a C code using opencv library. The code is not compiling because of the following issue:

/tmp/ccwgquWQ.o: In function `cvPointFrom32f':
try.c:(.text+0x54d): undefined reference to `cvRound'
try.c:(.text+0x563): undefined reference to `cvRound'
/tmp/ccwgquWQ.o: In function `cvReadInt':
try.c:(.text+0xe68): undefined reference to `cvRound'
/tmp/ccwgquWQ.o: In function `cvEllipseBox':
try.c:(.text+0x10d4): undefined reference to `cvRound'
try.c:(.text+0x10f6): undefined reference to `cvRound'
collect2: error: ld returned 1 exit status

I have asked a question related to this in stackoverflow and I got the response saying that, its a bug present in opencv3.2. [http://stackoverflow.com/questions/42918747/yolo-c-compilation-failure-with-debug-1]

The reason for calling it as a bug is as follows:
CvRound function has bee defines in types_c.h in opencv2 whereas in opencv3 its not been defined in types_c.h but in core/fast_math.hpp. Despite being not defined in types_c.h its still being called in types_c.h, core_c.h and imgproc_c.h without any reference to fast_math.hpp

I have tried including the "fast_math.hpp" path (#include core/fast_math.hpp) in types_c.h, core_c.h and imgproc_c.h but it didn't solve the issue.

Kindly, look into this issue and get it resolved as early as possible

duplicate wontfix

Most helpful comment

Thats really strange. There are many implementations in C using CUDA and OpenCV and are popular. What about such implementations then ? eg: YOLO

All 3 comments

run a C code

OpenCV is C++ library. There is no support for direct C compilation, it doesn't work (crash sometimes, see cvGetSize (#6221) problem). Also OpenCV C API is candidate for removal.

You should compile your program as C++ to use OpenCV.

Thats really strange. There are many implementations in C using CUDA and OpenCV and are popular. What about such implementations then ? eg: YOLO

Regarding to YOLO specially refer to answer https://stackoverflow.com/a/46808785/2953509

Was this page helpful?
0 / 5 - 0 ratings