0

我是 C++ 新手,但我需要使用 opencv 做一个项目。我已经下载了 opencv-4.5.2 和 opencv_contrib,我正在使用 Visual 2019。我使用了 cmake,但没有出现错误。

然后在我包含的项目中,“C:\opencv\opencv_lib\install\include”目录为 C++ 附加包含目录对于我包含的链接器,“C:\opencv\opencv_lib\install\x64\vc16\lib "用于附加库目录。我在其他依赖项中包含了“opencv_core452.lib,opencv_highgui452.lib,opencv_imgcodecs452.lib”。我已经为路径添加了“C:...opencv\build\x64\vc14\bin”

当我运行一个简单的项目时,似乎出了点问题,我不确定它是什么。以下是错误:

严重性代码 描述 项目文件行抑制状态

  1. 错误 LNK2019 未解析的外部符号“public: class cv::Mat & __thiscall cv::Mat::operator=(class cv::Mat &&)”(??4Mat@cv@@QAEAAV01@$$QAV01@@Z) 引用在函数 _main protorype C:...\protorype.obj 1
  2. 函数 _main protorype C:...\protorype.obj 1 中引用的错误 LNK2019 未解析的外部符号“public: __thiscall cv::Mat::Mat(void)”(??0Mat@cv@@QAE@XZ)
  3. 函数 _main protorype C:...\protorype.obj 1 中引用的错误 LNK2019 未解析的外部符号“public: __thiscall cv::Mat::~Mat(void)”(??1Mat@cv@@QAE@XZ)
  4. 错误 LNK2019 未解析的外部符号“class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,int)”(?imread@cv@@ YA?AVMat@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) 在函数 _main protorype C:...\protorype 中引用.obj 1
  5. 错误 LNK2019 未解析的外部符号“void __cdecl cv::namedWindow(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,int)”(?namedWindow@cv@@YAXABV?$basic_string @DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) 在函数 _main protorype C:...\protorype.obj 1 中引用
  6. 错误 LNK2019 未解析的外部符号“void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class cv::debug_build_guard::_InputArray const &)”(? imshow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV_InputArray@debug_build_guard@1@@Z) 在函数_main protorype C:中引用。 ..\prototype.obj 1
  7. 错误 LNK1120 6 无法解析的外部原型 C:...\protorype.exe 1

因为我是新手,请用简单的话解释我如何解决它。先感谢您!

4

1 回答 1

0

我终于找到了。我不知道,可能即使我使用了正确的库并使用了正确的目录,我还是决定将所有库复制到依赖项中,而不仅仅是我使用的那些并且它可以工作。这是我案例的所有目录,但请注意,如果您使用不同的版本,它们可能会有所不同。

opencv_aruco452d.lib opencv_barcode452d.lib opencv_bgsegm452d.lib opencv_bioinspired452d.lib opencv_calib3d452d.lib opencv_ccalib452d.lib opencv_core452d.lib opencv_datasets452d.lib opencv_dnn_objdetect452d.lib opencv_dnn_superres452d.lib opencv_dnn452d.lib opencv_dpm452d.lib opencv_face452d.lib opencv_features2d452d.lib opencv_flann452d.lib opencv_fuzzy452d.lib opencv_gapi452d.lib opencv_hdf452d.lib opencv_hfs452d.lib opencv_highgui452d.lib opencv_img_hash452d.lib opencv_imgcodecs452d.lib opencv_imgproc452d.lib opencv_intensity_transform452d.lib opencv_line_descriptor452d.lib opencv_mcc452d.lib opencv_ml452d.lib opencv_objdetect452d.lib opencv_optflow452d.lib opencv_phase_unwrapping452d.lib opencv_photo452d.lib opencv_plot452d.lib opencv_quality452d.lib opencv_rapid452d.lib opencv_reg452d.lib opencv_rgbd452d.lib opencv_saliency452d.lib opencv_shape452d.lib opencv_stereo452d.lib opencv_stitching452d.lib opencv_structured_light452d.lib opencv_superres452d.lib opencv_surface_matching452d.lib opencv_text452d.lib opencv_tracking452d.lib opencv_video452d.lib opencv_videoio452d.lib opencv_videostab452d.lib opencv_wechat_qrcode452d.lib opencv_xfeatures2d452d.lib opencv_ximgproc452d.lib opencv_xobjdetect452d.lib opencv_xphoto452d.lib
于 2021-07-12T18:47:11.860 回答