OpenCV : undefined reference to imread()

后端 未结 3 1870
鱼传尺愫
鱼传尺愫 2021-02-12 23:52

I have configured OpenCV 3.1.0 in Eclipse Mars. These are my configuration,

G++ includes: D:/opencv/build/install/include; GCC includes

相关标签:
3条回答
  • 2021-02-13 00:12

    Since OpenCV3, the imread function resides in the imgcodecs module. Imread should work once you add the opencv_imgcodecs library to your project (note: imgcodecs, not imcodecs).

    0 讨论(0)
  • 2021-02-13 00:27

    I recommend to link the following libraries:

    opencv_core
    opencv_highgui
    opencv_imgproc
    opencv_imgcodecs
    

    And in the .cpp file, you can include like this

        #include <iostream>
        #include <opencv2/core/core.hpp>
        #include <opencv2/highgui/highgui.hpp>
        #include <opencv2/imgproc/imgproc.hpp>
    
        using namespace std;
        using namespace cv;
    

    Or

        #include <iostream>
        #include <opencv2/opencv.hpp>
    
        using namespace std;
        using namespace cv;
    
    0 讨论(0)
  • 2021-02-13 00:33

    This function is located in opencv_imgcodecs library. It also worths mentioning that you may need to put your object file before libraries in order to link successfully:

    g++ -c -I/usr/include/opencv4/opencv -I/usr/include/opencv4 main.cpp
    g++ main.o -lopencv_imgcodecs $(OTHER_FLAGS) -o main
    
    0 讨论(0)
提交回复
热议问题