如何以及在何处为Visual C++ OpenCV项目添加调试符号

dum*_*dad 0 c++ debugging opencv visual-studio visual-c++

我在Visual Studio 2012中设置了一个OpenCV C++项目.为了使它工作,我使用了各种项目属性页面

  1. 其他包含目录:$(SolutionDir)..\Libs\OpenCV\2.4.6\include
  2. 其他库目录:$(SolutionDir)..\Libs\OpenCV\2.4.6\$(平台)\ $(配置)
  3. 附加依赖项:各种文件包括 opencv_highgui246d.dll
  4. 构建后事件,命令行:复制DLL和lib文件以及一些示例内容:

    xcopy/y $(SolutionDir)..\Libs\OpenCV\2.4.6\$(平台)\ $(配置)*.dll $(ProjectDir)$(平台)\ $(配置)\ xcopy/y $(SolutionDir )..\Libs\OpenCV\2.4.6\$(平台)\ $(配置)*.lib $(ProjectDir)$(平台)\ $(配置)\ xcopy/y $(ProjectDir)opencv-logo.jpg $(ProjectDir)$(平台)\ $(配置)\ xcopy/y $(ProjectDir)sample.wmv $(ProjectDir)$(平台)\ $(配置)\

我试图调试的代码行与VideoCapture这里给出的OpenCV类的示例代码中的代码行大致相同:http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html

VideoCapture cap(0); // open the default camera
if(!cap.isOpened())  // check if we succeeded
    return -1;
Run Code Online (Sandbox Code Playgroud)

但我正在打开一个文件

VideoCapture cap ("sample.wmv");
if (FileExists("sample.wmv"))
{
    OutputDebugString("File exists\n");
}
else
{
    OutputDebugString("File does not exist\n");
}
if(!cap.isOpened())
{
    cout <<"Failed to open camera" << endl;
    OutputDebugString("Failed to open camera\n");   
    return -1;
}
Run Code Online (Sandbox Code Playgroud)

出了点问题所以我想cap通过在线上设置断点来检查属性是什么if(!cap.isOpened()).但是,如果我尝试cap在Visual Studio 2012中的本地窗口中检查,我会收到错误:

"信息不可用,没有为opencv_highgui246d.dll加载符号"

我不熟悉在Visual Studio中设置C++项目(我多年来一直使用C#); 我需要做什么才能启用此调试?我是否必须自己构建OpenCV(如果是这样,我应该在哪里使用)或者是否有更多文件可以复制并包含在我的构建中?

ber*_*rak 5

  • 问题:您正在使用2.4.6附带的预构建库,您将能够调试自己的代码但不能深入了解opencv库(如highgui246d.dll).

  • 原因:没有提供所需的pdb文件(想想看,这会将下载量扩大到千兆字节范围)

  • 补救措施:如果你真的需要在调试时深入挖掘opencv库,你将不得不重新编译它们(cmake和所有jive),因为这将实际生成所需的pdb文件