我按照本教程在 Macbook M1 中构建了 OpenCV-4.5.2:https: //sayak.dev/install-opencv-m1。它在 Python 中工作正常,但当我在 C++ 中使用时
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
int main()
{
cv::Mat img = cv::imread("avatar.jpeg");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它在 cv::Mat 中给出错误
Undefined symbols for architecture arm64:
"cv::Mat::~Mat()", referenced from:
_main in main.cpp.o
"cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [imgproc] Error 1 …Run Code Online (Sandbox Code Playgroud)