我正在尝试使用Visual Studio构建C ++ dll并在python中加载该dll。 dll代码
#define DLLEXPORT extern "C" __declspec(dllexport)
#include "test.h"
#include "opencv2\\highgui.hpp"
using namespace cv;
DLLEXPORT int sumV() {
Mat a = Mat::zeros(5,5, CV_8U);
return 11;
}
并且python代码是
from ctypes import *
from ctypes.util import *
dll = find_library('C:\\path\\dll1.dll')
lib = cdll.LoadLibrary(dll)
我总是收到“ OSError:[WinError 126]找不到指定的模块。”当我运行python代码时。
有人知道如何解决此问题吗?非常感谢。
这是我解决问题的方式。在我的C ++代码中,我调用了opencv函数,但是忘记了将opencv dll复制到我的python脚本文件夹中。因此,python无法找到它。再次感谢Yunus的帮助。