Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用opencv和visual studio 2019安装BGSlibrary时出现问题_C++_Cmake_Visual Studio 2019 - Fatal编程技术网

C++ 使用opencv和visual studio 2019安装BGSlibrary时出现问题

C++ 使用opencv和visual studio 2019安装BGSlibrary时出现问题,c++,cmake,visual-studio-2019,C++,Cmake,Visual Studio 2019,所以我在一周前问了一个类似的问题,并被发送到一个链接器错误的线程。 我现在已经通读了所有的错误,并用cmake对包括OpenCV在内的所有内容进行了完全干净的安装 问题是,当我现在正确添加项目时,仍然会出现相同的链接器错误。我使用cmake构建了这个项目,并将库文件添加到依赖项中,将库目标添加到库目录中 就是这个库,我遵循cmake步骤作为集成步骤,我真的对我现在所能做的感到迷茫 如果有人能给我解释一下这一点,我会非常感激,因为我确信我做的每件事都是对的,但仍然得到了错误的答案 这是我采取的所

所以我在一周前问了一个类似的问题,并被发送到一个链接器错误的线程。 我现在已经通读了所有的错误,并用cmake对包括OpenCV在内的所有内容进行了完全干净的安装

问题是,当我现在正确添加项目时,仍然会出现相同的链接器错误。我使用cmake构建了这个项目,并将库文件添加到依赖项中,将库目标添加到库目录中

就是这个库,我遵循cmake步骤作为集成步骤,我真的对我现在所能做的感到迷茫

如果有人能给我解释一下这一点,我会非常感激,因为我确信我做的每件事都是对的,但仍然得到了错误的答案

这是我采取的所有步骤的照片: ,在释放模式下

求你了,我真的迷路了

附言: 在遵循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)

对于那些至少知道如何在VisualStudio2019中安装库和设置东西的人来说,我遇到的问题是,我正在以不同的配置构建不同的版本


我在调试Win32中构建了OpenCV,并尝试在版本x64中构建了BgsLibrary。在drescherjm谈到OpenCV构建中可能存在的问题之后,我从头开始重新构建了OpenCV,但这次是在Win32版本中(因为bgslibrary要求您在版本中构建)。之后,我又从头开始构建了bgslibrary,但这次也是在Win32版本中。在那之后,它只是将所有库链接起来,并将.dll位置添加到我的路径中,它就成功了

使用
cmake
MSVC
最简单的方法是使用

因此,请遵循
vcpkg
(构建此工具)的说明,使用该工具安装
OpneCV

然后在
CMakeLists.txt
中,只需使用
find_package(需要OpenCV)
就可以了。
有关更多详细信息,请参阅如何将OpenCV与
cmake
一起使用


额外的好处是,如果有人将使用package manager在MacOS上安装OpenCV(有人正在使用自制软件),这也适用于Linux。

您也构建了OpenCV吗?我猜在您调用“成功构建后”的步骤中出现的错误是,您正在构建bgslibrary,但没有构建opencv。我也使用cmake构建了opencv,并且我已经测试了opencv是否运行,它是否运行:)构建opencv后,返回到“成功构建后”步骤和构建,看看关于找不到opencv库的错误是否仍然存在。请不要“照片”。相反,将粘贴输出和其他相关信息作为文本复制到问题帖子中。另请参见。很抱歉Tsyvarev下次会这么做!我已经回到了步骤,遗憾的是错误仍然存在,descherjm
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'