如何在Visual C ++中调试外部库(OpenCV)? [英] How to debug an external library (OpenCV) in Visual C++?

查看:150
本文介绍了如何在Visual C ++中调试外部库(OpenCV)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VC ++ 2008中开发一个项目。该项目使用OpenCV库(但我认为这适用于任何其他库)。我正在使用Debug配置,链接器属性包括库.lib作为附加依赖项的调试版本。在VC ++目录下的工具|选项下,我设置了include目录,.lib目录,库的源目录。在从库中调用其中一个函数时,我收到错误,我想看看该功能正在做什么。产生错误的行是:

  double error = cvStereoCalibrate(& calObjPointsM,& img1PointsM,& img2PointsM,
& pointCountsM,
& cam1M,& dist1M,& cam2M,& dist2M,imgSize& rotM& transM,NULL,NULL,
cvTermCriteria(CV_TERMCRIT_ITER + CV_TERMCRIT_EPS ,100,1e-5));

我在此行设置了一个断点,以查看cvStereoCalibrate()函数如何失败。不幸的是,当我点击进入时,调试器不会显示此函数的源代码。它会立即跳到cvTermCriteria()(这是一个简单的内联,宏类函数),并显示其内容。还有什么我需要做的才能在调试器中输入外部库函数?



编辑:我认为cvTermCriteria()函数在调试器中显示,因为它在头文件中定义,因此可以立即访问项目。



EDIT2:库文件缺少.pdb文件,现在我重新编译了OpenCV库Visual C ++在Debug配置中,.pdb文件存在但仍然以某种方式对调试器不可见:


加载'C:\Users\\ \\ DarekSz\Documents\Visual Studio 2008\Projects\libcci\Debug\ccisample.exe',加载符号。

'ccisample.exe':加载'C:\Windows\\ \\ sysWOW64\\\
tdll.dll'

'ccisample.exe':加载'C:\Windows\SysWOW64\kernel32.dll'

'ccisample.exe':加载'C:\Windows\SysWOW64\KernelBase.dll'

'ccisample.exe':Lo C:\OpenCV2.1\bin\cv210d.dll

'ccisample.exe':加载'C:\OpenCV2.1\bin\cxcore210d.dll' / p>

这些符号没有明显加载到opencv dll。仍然,.pdb文件存在于\bin目录中。

解决方案

总结注释中的所有活动:解决方案的关键是在VC ++中重建库,以获取用于调试的.pdb(程序调试数据库)文件,预编译的-d后缀库是不够的。尽管如此,库DLL的导入库使程序从OpenCV包树中加载预编译的dll,而不是从我的构建中添加了.pdb信息(路径类似,所以我没有注意到)。 .pdb文件的路径在工具选项中提供,但由于模块版本不匹配,这些文件未加载。一旦我将正确的dll和他们各自的.pdb文件复制到应用程序目录中,调试器就开始在库函数中工作。


I am developing a project in VC++2008. The project uses the OpenCV library (but I guess this applies to any other library). I am working with the Debug configuration, the linker properties include the debug versions of the library .lib's as additional dependencies. In VC++ Directories under Tools|Options i set up the include directory, the .lib directory, the source directories for the library as well. I get an error while calling one of the functions from the library and I'd like to see exactly what that function is doing. The line that produces the error is:

double error = cvStereoCalibrate(&calObjPointsM, &img1PointsM, &img2PointsM,
 &pointCountsM, 
 &cam1M, &dist1M, &cam2M, &dist2M, imgSize, &rotM, &transM, NULL, NULL,
 cvTermCriteria(CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, 100, 1e-5));

I set up a breakpoint at this line to see how the cvStereoCalibrate() function fails. Unfortunately the debugger won't show the source code for this function when I hit "Step into". It skips immediately to the cvTermCriteria() (which is a simple inline, macro-kinda function) and show its contents. Is there anything else I need to do to be able to enter the external library functions in the debugger?

EDIT: I think the cvTermCriteria() function shows in the debugger, because it's defined in a header file, therefore immediately accesible to the project.

EDIT2: The .pdb files were missing for the library files, now I recompiled the OpenCV library in Visual C++ in Debug configuration, the .pdb files exist but are still somehow invisible to the debugger:

Loaded 'C:\Users\DarekSz\Documents\Visual Studio 2008\Projects\libcci\Debug\ccisample.exe', Symbols loaded.
'ccisample.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'ccisample.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'ccisample.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'ccisample.exe': Loaded 'C:\OpenCV2.1\bin\cv210d.dll'
'ccisample.exe': Loaded 'C:\OpenCV2.1\bin\cxcore210d.dll'

The symbols aren't loaded apparently for the opencv dlls. Still, the .pdb files exist in the \bin directory.

解决方案

To sum up all the activity in the comments: the key to the solution was to rebuild the library in VC++ to obtain the .pdb (Program Debug Database) files for debugging, the precompiled "-d" suffix libraries weren't enough. Still, the import libs for the library dlls made the program load precompiled dlls from the OpenCV package tree, not the ones from my build with the .pdb information (the paths were similar so I didn't notice at first). The path to the .pdb files was provided in Tools|Options, but these files weren't loaded because of module version mismatch (obviously). Once I copied the correct dlls and their respective .pdb files to the application directory, the debugger started working inside the library functions.

这篇关于如何在Visual C ++中调试外部库(OpenCV)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆