Undefined References to OpenCV

15,688

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.

Share:
15,688
eboix
Author by

eboix

Updated on June 04, 2022

Comments

  • eboix
    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 in 3rdParty/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
    eboix almost 12 years
    I just searched for it in my OpenCV folder, but I can't find it. Do you know where it is located?
  • Alex
    Alex almost 12 years
    @eboix Did you compiled sources?
  • eboix
    eboix almost 12 years
    Sorry for the delay in my response. I didn't compile the source. I just downloaded the already-compiled OpenCV2.2.
  • eboix
    eboix almost 12 years
    Actually, it seems that I included opencv_imgproc220d.lib and opencv_imgproc220.lib. I'm not sure if these are the libopencv_imgproc you're talking about.
  • Alex
    Alex almost 12 years
    @eboix Yes, it can be so. I worked with opencv under linux, so it was libopencv_imgproc.a or libopencv_imgproc.so after library compilation.
  • eboix
    eboix almost 12 years
    So I should download OpenCV source and use CMake and make?
  • eboix
    eboix almost 12 years
    Okay. I'll accept this answer and proceed to building OpenCV from the source.