记录:LINUX下,编译一个调用了OPENCV库的程序出错的解决方法

记录:LINUX下,编译一个调用了OPENCV库的程序出错的解决方法

大致错误如下:

usr/local/lib/libopencv_highgui.a(grfmt_jpeg2000.cpp.o): in function `cv::Jpeg2KDecoder::readData(cv::Mat&)': grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x5b7): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'

解决方法:

调整链接库的顺序,原先的链接顺序是 -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml ...

修改为 -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_core ...

推荐阅读