OpenCV 3 的"ld: symbol(s) not found for architecture x86_64"
"ld: symbol(s) not found for architecture x86_64" for OpenCV 3
我已经在mac Yosemite上使用CMAKE安装了OPENCV 3。我正在使用Eclipse IDE,在构建解决方案时显示错误:
g++ -L/usr/local/lib -o "test1" ./main.o -lopencv_imgcodecs -lopencv_highgui -lopencv_core
Undefined symbols for architecture x86_64:
"cv::VideoCapture::read(cv::_OutputArray const&)", referenced from:
_main in main.o
"cv::VideoCapture::VideoCapture(int)", referenced from:
_main in main.o
"cv::VideoCapture::~VideoCapture()", referenced from:
_main in main.o
"cv::VideoCapture::get(int) const", referenced from:
_main in main.o
"cv::VideoCapture::isOpened() const", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test1] Error 1
我在设置中添加了头文件和库。请帮我去掉这个错误。提前感谢
代码:#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
VideoCapture cap(0); // open the video camera no. 0
if (!cap.isOpened()) // if not success, exit program
{
cout << "Cannot open the video cam" << endl;
return -1;
}
double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
cout << "Frame size : " << dWidth << " x " << dHeight << endl;
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
while (1)
{
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read a frame from video stream" << endl;
break;
}
imshow("MyVideo", frame); //show the frame in "MyVideo" window
if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
return 0;
}
您可以尝试在macos上这样编译:
g++ -I /usr/local/Cellar/opencv/4.5.0_5/include/opencv4/ -L /usr/local/Cellar/opencv/4.5.0_5/lib-l opencv_core -l opencv_imgcodecs -l opencv_imgproc -l opencv_highgui -l opencv_videoio <filename>.cpp
你可能需要或多或少在你的编译,但关键是库被链接,据我所知。
Make Sure检查文件夹以查看您的版本以及它们是否存在等
相关文章:
- "error: no matching function for call to"构造函数错误
- 解决"ld: library not found for -ltensorflow_framework.2.3.0"
- Android Studio 3.1.2 - 无法运行C++子例程"No implementation found for Java.lang.String..."
- Vtk 图表在 QT 中突破,"no override found for 'vtkContextDevice2D"
- NetBeans for C/C++ 说"no compiler found"
- 当 pip 安装 scikit-learn "ld: library not found for -lc++"
- Microsoft Visual Studio - 'The build tools for v140 cannot be found'
- 启用 openmp 时出错 - "ld: library not found for -lgomp" 和 Clang 错误
- 安装摩西翻译软件。错误消息:"ld: library not found for -lboost_thread"
- 有错误"Undefined symbols for architecture x86_64"和"ld: symbol(s) not found for architecture x86_64"
- Xcode 警告:"directory not found for option"
- 警告'RTTI symbol not found for class'是什么意思?
- OpenCV 3 的"ld: symbol(s) not found for architecture x86_64"
- 神秘的构建错误"symbol(s) not found for i386" - openFrameworks 像素操作
- Xcode 错误"not found for architecture" 。尝试不使用库的基本C++
- 示例 XSD 失败并显示"error: no declaration found for element X"
- 编译 cmake 代码时获取"ld: symbol(s) not found for architecture x86_64"
- 操作系统字距错误: "ld: symbol(s) not found for architecture x86_64"
- OSX "clang++ -lboost_mpi" ' -> "ld: library not found for -lboost_mpi" 后冲泡安装提升 --with-mpi
- g++ ld: symbol(s) not found for architecture x86_64 -没有更具体的错