【发布时间】:2021-05-19 14:33:21
【问题描述】:
所以我一周前问了一个类似的问题,并被发送到一个线程以查找链接器错误。 我现在已经阅读了所有错误,并使用 cmake 对包括 OpenCV 在内的所有内容进行了完整的全新安装。
问题是,当我现在正确添加项目时,仍然会出现相同的链接器错误。我已经使用 cmake 构建了项目,并将库文件添加到依赖项中,并将库目标添加到库目录中。
https://github.com/andrewssobral/bgslibrary/tree/master 就是这个库,我按照 cmake 步骤作为集成步骤,老实说,我只是迷失了我现在能做的事情。
如果有人可以简单地向我解释这一点,我将不胜感激,因为我很确定我所做的一切都是正确的,但仍然得到错误的答案
我采取的所有步骤的照片: Initial Clone、Cmake、After a succesful build 处于释放模式。 Errors after implementing 1 line of code, The implementation that brings up the error
拜托我真的迷路了。
PS: 在遵循 Drescherjms 的回答后,我重建了我的 OpenCV,但这次是在发布模式下(正如他们所指出的,错误是它找不到那个 .lib 文件)。这解决了没有发现的问题,但在构建时添加了许多在此之前不存在的新链接器错误。我将在此处粘贴其中的一些:
3>Main.obj : error LNK2019: unresolved external symbol "void __cdecl cv::destroyAllWindows(void)" (?destroyAllWindows@cv@@YAXXZ) referenced in function "public: static void __cdecl bgslibrary::Main::start(int,char const * *)" (?start@Main@bgslibrary@@SAXHPEAPEBD@Z)
3>Main.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z) referenced in function "public: static void __cdecl bgslibrary::Main::start(int,char const * *)" (?start@Main@bgslibrary@@SAXHPEAPEBD@Z)
3>VideoAnalysis.obj : error LNK2001: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z)
3>VideoCapture.obj : error LNK2001: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z)
3>PreProcessor.obj : error LNK2019: unresolved external symbol "public: class cv::Mat __cdecl cv::Mat::clone(void)const " (?clone@Mat@cv@@QEBA?AV12@XZ) referenced in function "public: class cv::Mat __cdecl bgslibrary::PreProcessor::getGrayScale(void)" (?getGrayScale@PreProcessor@bgslibrary@@QEAA?AVMat@cv@@XZ)
3>PreProcessor.obj : error LNK2019: unresolved external symbol "public: bool __cdecl cv::Mat::empty(void)const " (?empty@Mat@cv@@QEBA_NXZ) referenced in function "public: void __cdecl bgslibrary::PreProcessor::applyCanny(class cv::Mat const &,class cv::Mat &)" (?applyCanny@PreProcessor@bgslibrary@@QEAAXAEBVMat@cv@@AEAV34@@Z)
3>VideoCapture.obj : error LNK2001: unresolved external symbol "public: bool __cdecl cv::Mat::empty(void)const " (?empty@Mat@cv@@QEBA_NXZ)
3>PreProcessor.obj : error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@1@@Z) referenced in function "public: void __cdecl bgslibrary::PreProcessor::process(class cv::Mat const &,class cv::Mat &)" (?process@PreProcessor@bgslibrary@@QEAAXAEBVMat@cv@@AEAV34@@Z)
3>VideoCapture.obj : error LNK2001: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@1@@Z)
3>PreProcessor.obj : error LNK2019: unresolved external symbol "void __cdecl cv::GaussianBlur(class cv::_InputArray const &,class cv::_OutputArray const &,class cv::Size_<int>,double,double,int)" (?GaussianBlur@cv@@YAXAEBV_InputArray@1@AEBV_OutputArray@1@V?$Size_@H@1@NNH@Z) referenced in function "public: void __cdecl bgslibrary::PreProcessor::process(class cv::Mat const &,class cv::Mat &)" (?process@PreProcessor@bgslibrary@@QEAAXAEBVMat@cv@@AEAV34@@Z)
3>PreProcessor.obj : error LNK2019: unresolved external symbol "void __cdecl cv::Canny(class cv::_InputArray const &,class cv::_OutputArray const &,double,double,int,bool)" (?Canny@cv@@YAXAEBV_InputArray@1@AEBV_OutputArray@1@NNH_N@Z) referenced in function "public: void __cdecl bgslibrary::PreProcessor::applyCanny(class cv::Mat const &,class cv::Mat &)" (?applyCanny@PreProcessor@bgslibrary@@QEAAXAEBVMat@cv@@AEAV34@@Z)
3>PreProcessor.obj : error LNK2019: unresolved external symbol "double __cdecl cv::threshold(class cv::_InputArray const &,class cv::_OutputArray const &,double,double,int)" (?threshold@cv@@YANAEBV_InputArray@1@AEBV_OutputArray@1@NNH@Z) referenced in function "public: void __cdecl bgslibrary::PreProcessor::applyCanny(class cv::Mat const &,class cv::Mat &)" (?applyCanny@PreProcessor@bgslibrary@@QEAAXAEBVMat@cv@@AEAV34@@Z)
还添加了这些警告以防万一它们有用
3>D:\GitRepos\opencv\build\lib\Release\opencv_gapi452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
3>D:\GitRepos\opencv\build\lib\Release\opencv_highgui452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
3>D:\GitRepos\opencv\build\lib\Release\opencv_ml452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
3>D:\GitRepos\opencv\build\lib\Release\opencv_objdetect452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
3>D:\GitRepos\opencv\build\lib\Release\opencv_photo452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
3>D:\GitRepos\opencv\build\lib\Release\opencv_stitching452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
3>D:\GitRepos\opencv\build\lib\Release\opencv_video452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
3>D:\GitRepos\opencv\build\lib\Release\opencv_calib3d452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
3>D:\GitRepos\opencv\build\lib\Release\opencv_dnn452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
3>D:\GitRepos\opencv\build\lib\Release\opencv_features2d452.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
【问题讨论】:
-
你也构建了opencv吗?我猜测您调用“成功构建后”的步骤中的错误是您正在构建 bgslibrary 但没有构建 opencv。
-
我也使用 cmake 构建了 OpenCV,并且我已经测试过 OpenCV 是否可以运行:)
-
构建opencv后,返回“构建成功后”步骤,构建并查看关于找不到opencv库的错误是否仍然存在。
-
请不要“照片”。相反,将粘贴输出和其他相关信息作为 text 复制到问题帖子中。另请参阅How to Ask。
-
对不起,Tsyvarev 下次会这样做!我已经回到这一步,但遗憾的是错误仍然存在,descherjm
标签: c++ cmake visual-studio-2019