简体   繁体   English

OpenCV:使用imwrite()函数时无法编译

[英]OpenCV: cannot compile when using imwrite() function

In my simple first OpenCV application I want to save frames got by cam so I am using imwrite() as tutorial say. 在我简单的第一个OpenCV应用程序中,我想保存由cam获取的帧,所以我使用imwrite()作为教程说。 The problem, is that I can't compile because I get this error: 问题是,我无法编译因为我收到此错误:

Undefined symbols for architecture x86_64:
"cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int,  std::allocator<int> > const&)", referenced from:
_main in video-87ad7a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reading some posts here in SO I have discovered it's a problem about the C++ standard library which is used, so I added the flag libstdc++ but the following: 在SO中阅读一些帖子我发现它是一个关于使用的C ++标准库的问题,所以我添加了标志libstdc++但是以下内容:

g++ -stdlib=libstdc++ -I/usr/local/include -L/usr/local/lib/ -g -o binary video.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_stitching -lopencv_videoio -lopencv_videostab

has not solved the problem. 还没有解决问题。 How shall I do? 我该怎么办?

UPDATE it seems this is the solution. 更新似乎是解决方案。 I don't know what was the damned flag I was missing 我不知道我失踪的该死的旗帜是什么

Looks like you are missing '-lopencv_imgcodecs' where imwrite() lives. 看起来你错过了'-lopencv_imgcodecs',其中imwrite()存在。
Refer to OpenCV imgcodecs header file here . 请在此处参阅OpenCV imgcodecs头文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM