1.
错误
CMakeFiles/opencv_example.dir/example.cpp.o:在函数‘main’中:
example.cpp:(.text+0x12c):对‘cv::imshow(cv::String const&, cv::_InputArray const&)’未定义的引用
example.cpp:(.text+0x21d):对‘cv::imshow(cv::String const&, cv::_InputArray const&)’未定义的引用
CMakeFiles/opencv_example.dir/example.cpp.o:在函数‘drawText(cv::Mat&)’中:
example.cpp:(.text+0x3fe):对‘cv::putText(cv::InputOutputArray const&, cv::String const&, cv::Point, int, double, cv::Scalar_, int, int, bool)’未定义的引用
CMakeFiles/opencv_example.dir/example.cpp.o:在函数‘cv::String::String(char const*)’中:
example.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4d):对‘cv::String::allocate(unsigned long)’未定义的引用
CMakeFiles/opencv_example.dir/example.cpp.o:在函数‘cv::String::~String()’中:
example.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14):对‘cv::String::deallocate()’未定义的引用
collect2: error: ld returned 1 exit status
CMakeFiles/opencv_example.dir/build.
cmake编译opencv报错
最新推荐文章于 2025-10-06 03:49:12 发布
在尝试使用CMake编译包含OpenCV的项目时,遇到了多个未定义的引用错误,如`cv::imshow`和`cv::putText`。错误源于找不到对应的OpenCV库。通过在CMakeLists.txt中正确指定OpenCV的版本(例如`find_package(OpenCV 3.3.0 REQUIRED)`),可以解决问题。这可能是因为先前的配置错误导致CMake使用了错误的OpenCV版本。

最低0.47元/天 解锁文章
1047

被折叠的 条评论
为什么被折叠?



