Undefined References to OpenCV
Solution 1
You need to include the libopencv_imgproc
library.
Solution 2
I had the same problem and tried the above which did not work and I have downloaded the precompiled OpenCV.
So what worked for me was to include the following header.
include opencv2\imgproc\imgproc.hpp
Hope this helps.
eboix
Updated on June 04, 2022Comments
-
eboix almost 2 years
I'm running 32-bit Windows 7 Enterprise and CodeBlocks 10.05.
I followed this tutorial to set up OpenCV 2.2 to work with CodeBlocks.
Any programs that use the C CodeBlocks API work fine - they compile, link, and run fine. However, when I try to use C++ OpenCV functions and objects,
.o
files are generated, but I get linking errors, such as:undefined reference to
`cv::cvtColor(cv::Mat const&, cv::Mat&, int, int)'
After some Googling, I found that this was because I didn't include enough libraries in my search directories. However, I don't know what libraries to include.
After some searching in my OpenCV folder, I found some
.a
files in3rdParty/lib
and added them, too. But my problem persists.Does anyone know what libraries I have to include in order to get my program to work?
If you need more information, please tell me and I'll give it to you.
-
eboix almost 12 yearsI just searched for it in my OpenCV folder, but I can't find it. Do you know where it is located?
-
Alex almost 12 years@eboix Did you compiled sources?
-
eboix almost 12 yearsSorry for the delay in my response. I didn't compile the source. I just downloaded the already-compiled OpenCV2.2.
-
eboix almost 12 yearsActually, it seems that I included
opencv_imgproc220d.lib
andopencv_imgproc220.lib
. I'm not sure if these are thelibopencv_imgproc
you're talking about. -
Alex almost 12 years@eboix Yes, it can be so. I worked with opencv under linux, so it was
libopencv_imgproc.a
orlibopencv_imgproc.so
after library compilation. -
eboix almost 12 yearsSo I should download OpenCV source and use CMake and make?
-
eboix almost 12 yearsOkay. I'll accept this answer and proceed to building OpenCV from the source.