如何在不将 MFC 链接为静态库的情况下消除 OpenCV 1.1 和 MFC 6.0 之间的内存泄漏

How to remove memory leaks between OpenCV 1.1 and MFC 6.0 without linking MFC as static library(如何在不将 MFC 链接为静态库的情况下消除 OpenCV 1.1 和 MFC 6.0 之间的内存泄漏)

本文介绍了如何在不将 MFC 链接为静态库的情况下消除 OpenCV 1.1 和 MFC 6.0 之间的内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您曾经尝试将 MFC 和 OpenCV 一起使用,您会知道 这一点记录的问题.正如论坛所示,如果没有将 MFC 链接为静态库,使用 OpenCV 会产生内存泄漏.

If you ever tried to use MFC and OpenCV together, you would know this well documented problem. As the forum shows, without linking MFC as static library, using OpenCV creates memory leaks.

然而,一个人找到了解决这个问题的方法,方法是重新编译 OpenCV 并稍微更改代码.但它适用于 2.0 或更高版本.

A guy, however, found a way to resolve this problem by recompiling OpenCV with slightly changed code. But it was for 2.0 or later.

我想知道 OpenCV 1.0 或 1.1 是否有类似的方法.当然,这些版本中没有 system.cpp.有人试过吗?

I would like to know if there is a similar method for OpenCV 1.0 or 1.1. Of course, there is no system.cpp in those versions. Anybody tried this?

推荐答案

我没有要测试的 Visual Studio 6.0,但我在 Visual Studio 9 上遇到了这个问题,我所做的如下:

I don't have Visual Studio 6.0 to test on, but I had this problem on Visual Studio 9 and what I did was the following:

我去了 Project Properties/Linker/Input 并在 Delay Loaded DLLs 中添加了以下 DLL:

I went to Project Properties/Linker/Input and I added to the Delay Loaded DLLs the following DLLs:

opencv_core220d.dll;opencv_highgui220d.dll 在调试中

opencv_core220.dll;opencv_highgui220.dll 在发布中

我看到 Visual Studio 6.0 有这个选项.

这篇关于如何在不将 MFC 链接为静态库的情况下消除 OpenCV 1.1 和 MFC 6.0 之间的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何在不将 MFC 链接为静态库的情况下消除 OpenCV 1.1 和 MFC 6.0 之间的内存泄漏

基础教程推荐