0

I am trying to build a c++ dll using visual studio and load this dll in python. The dll code

#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;

}

and python code is

from ctypes import *
from ctypes.util import *

dll = find_library('C:\\path\\dll1.dll')
lib = cdll.LoadLibrary(dll)

I always got "OSError: [WinError 126] The specified module could not be found." when I run the python code.

Does anyone know how to solve this problem? thanks a lot.

fnhdx
  • 321
  • 2
  • 5
  • 14
  • Did you already check [this](https://stackoverflow.com/questions/1940578/windowserror-error-126-the-specified-module-could-not-be-found) – Yunus Temurlenk Jan 28 '20 at 05:26
  • Yes, I did, but no luck. I think it's not back slash issue since if I comment out Mat a = Mat::zeros(5,5, CV_8U); then it works fine. I also installed Redistributable and used release mode, but still got same problem. – fnhdx Jan 28 '20 at 15:45
  • 1
    I fixed the problem by coping opencv dll to the script folder. Thanks for the help. – fnhdx Jan 28 '20 at 15:59
  • I am happy you fixed your problem. You can answer your own question by explaining how to fix it properly. – Yunus Temurlenk Jan 28 '20 at 17:03

1 Answers1

0

Here is how I fixed the problem. In my c++ code, I called opencv function, but I forget copying the opencv dll to my python script folder. So python can't find it. Thanks Yunus again for the help.

fnhdx
  • 321
  • 2
  • 5
  • 14