Intel® Distribution of OpenVINO™ Toolkit
Community support and discussions about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all things computer vision-related on Intel® platforms.

unable to load custom C++ dll with OpenVINO

gdioni
New Contributor I
993 Views
I made a C# application with a C++ dll with OpenVINO on Windows 10. The application + dll runs fine on my laptop but doesn't work in another computer, even installing OpenVINO on the other computer didn't work(only the base OpenVINO, I haven't installed the other dependencies like python, cmake, vstudio since I only want the dlls to exist in the system). I have OpenVINO 2020.3.1 installed in the laptop to work with an Movidius NCS1. The error I get when I transfer the application+dll to another computer is "Unable to load DLL 'x.dll'. The specified module could not be found. (Exception from HRESULT: 0x8007007E)." From what I gathered online this error occurs because my C++ dll has dependencies on other dlls. I was able to find the dll it depends on they are: openvino\opencv\bin\opencv_highgui430.dll openvino\opencv\bin\opencv_imgproce430.dll openvino\opencv\bin\opencv_core430.dll openvino\...\inference_engine\...\inference_engine_legacy.dll openvino\...\inference_engine\...\inference_engine.dll openvino\...\ngraph.dll system32\MSVCP140.dll system32\VCRUNTIME140.dll system32\VCRUNTIME140_1.dll system32\kernel32.dll system32\ucrtbase.dll I'm trying things out but so far none of them have worked.
0 Kudos
1 Solution
gdioni
New Contributor I
860 Views

Solution: I was missing a folder in PATH for environment variable.

 

specifically C:\Program Files (x86)\IntelSWTools\openvino\inference_engine\external\tbb\bin

View solution in original post

14 Replies
gdioni
New Contributor I
988 Views

Sorry the formatting is off when I posted it, I'll just reformat it here instead:

 

I made a C# application with a C++ dll with OpenVINO on Windows 10. The application + dll runs fine on my laptop but doesn't work in another computer, even installing OpenVINO on the other computer didn't work(only the base OpenVINO, I haven't installed the other dependencies like python, cmake, vstudio since I only want the dlls to exist in the system).

 

I have OpenVINO 2020.3.1 installed in the laptop to work with an Movidius NCS1. The error I get when I transfer the application+dll to another computer is "Unable to load DLL 'x.dll'. The specified module could not be found. (Exception from HRESULT: 0x8007007E)."

 

From what I gathered online this error occurs because my C++ dll has dependencies on other dlls. I was able to find the dll it depends on they are:

  • openvino\opencv\bin\opencv_highgui430.dll
  • openvino\opencv\bin\opencv_imgproce430.dll
  • openvino\opencv\bin\opencv_core430.dll
  • openvino\...\inference_engine\...\inference_engine_legacy.dll
  • openvino\...\inference_engine\...\inference_engine.dll
  • openvino\...\ngraph.dll
  • system32\MSVCP140.dll
  • system32\VCRUNTIME140.dll
  • system32\VCRUNTIME140_1.dll
  • system32\kernel32.dll
  • system32\ucrtbase.dll

 

I'm trying things out but so far none of them have worked.

Iffa_Intel
Moderator
970 Views

Greetings,


Generally, OpenVINO requires all the pre-requisite to be available in order for it to work

  1. Intel® Distribution of OpenVINO™ toolkit core components
  2. Microsoft Visual Studio* with C++ 2019 or 2017 with MSBuild --the system32\MSVCP140.dll related to this
  3. CMake 3.10 or higher 64-bit
  4. Python 3.6 - 3.8 64-bit


without these, the OpenVINO won't be able to work properly.

If you are trying to deploy, you may refer here: https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_deployment_manager_tool.html



Sincerely,

Iffa


gdioni
New Contributor I
966 Views
Hi Iffa, Thank you very much for the reply. I will check them out and see which one's I need! I'll let you know if I've fixed the problem!
Iffa_Intel
Moderator
964 Views

Noted


Sincerely,

Iffa


gdioni
New Contributor I
959 Views

Ok. I'm still at the same problem.


What I've tried to the target computer:

  • Ran setupvars.bat
  • Installed VC++ 2015-2019 redistributable
  • Installed VC++ 2012 redistributable

These added some of the system32 dll files that wasn't present there before. Still has the same error.

 

I also tried using the deployment package you mentioned earlier. I was able to create a zip file that contained my application along with some of the library and dll files. I extracted the contents and kept the file structure as is but it still didn't run :(.

Iffa_Intel
Moderator
938 Views

Greetings,

 

You mentioned that you are using OpenVINO 2020.3, looking at deployment manager I don't think the tool has support for OpenCV which may be required by your application. Take a look at release notes https://software.intel.com/content/www/us/en/develop/articles/openvino-long-term-support-release.htm....

 

We had tested the deployment manager tool with classification_sample_async C++ app on OpenVINO 2021.2 and it works as expected. Make sure user data (see App User Data below) required by the application is included while creating the deployment archive (see Deployment Manager Selections below), as well as select components the application requires. Make sure Myriad driver has been installed in the target machine as mentioned in Pre-Requisitessection of Deployment Manager Guide 

https://docs.openvinotoolkit.org/2021.2/openvino_docs_install_guides_deployment_manager_tool.html.

You may take a look at the attachments also.

Hope this helps.

 

Sincerely,

Iffa

gdioni
New Contributor I
928 Views

Thank you for the reply. You're right, I don't see an OpenCV selection choice on my deployment manager interactive option, I'll worry about that later though but for now I have openvino base installed on the target computer.

 

My main app is failing on a simple test function to have the dll print 'Hello World' on my C# console on the target computer.

 

I made a clone application with the same C# app and C++ dll combination but I'm taking the tdd approuch. I'll find where it breaks when I slowly start adding more code/functionality.

 

I'll update my post as soon as I find where it breaks

Iffa_Intel
Moderator
924 Views

Noted, thanks for the update.



Sincerely,

Iffa


gdioni
New Contributor I
910 Views

Figured out what is causing the issue. In my dll export method. I have a function that frees a C++ Detector class

CPP_DLL void Free(Detector* instance) {
	// Causes error??
	if (instance != nullptr) {
		delete instance;
		instance = nullptr;
	}
}

 

However if I do have it empty like this, it runs fine

CPP_DLL void Free(Detector* instance) {

}

 

I've tried changing the detector class to also be dll export but that hasn't changed anything or changed null_ptr to NULL.

Iffa_Intel
Moderator
902 Views

That definitely means that your function has errors.

Please note that the type of the pointer has to match the type of the variable you're working with.


for void Free(Detector* instance) ----Detector is not a data type, you need to declare a variable with a suitable data type here

you may refer here: https://www.w3schools.com/cpp/cpp_function_multiple.asp


Try to workaround with this. you can remove the cout as it's only for display.


void Free(char* instance) {

  if (instance != nullptr) { cout << "instance is NOT null"; instance=nullptr; }

  else { cout << "instance is null"; }  


}



I don't think you need to use delete to the variable named instance as you still intend to use it, instead overwrite the value to null


In your main file:


int main()

{


  

Free(0); //where you call the function above & assign value to it, 0 = null

//Free("C++");



}


However, if this function is insignificant, better to remove it as you mentioned it works if you do so.



Sincerely,

Iffa



gdioni
New Contributor I
897 Views

 

I'm using the 'new' operator to pass a c++ class pointer back for the to c#. Free 'deletes' the class.

 

I did find what is the issue though, when the DLL has to start referencing inference engine stuff then it causes the issue.

for example:

// Works
_declspec(dllexport) Dummy* Init() {
	Dummy* b = 0;
	return b;
}

// Doesn't Work
_declspec(dllexport) Dummy* Init() {
	InferenceEngine::Core ie;
	Dummy* b = 0;
	return b;
}

 

I guess its just a deployment issue. I would prefer not to have to install all the dependencies because they don't make sense to install.

gdioni
New Contributor I
893 Views

Also OpenCV runs fine on the target computer, i did a separate test. Only Inference engine is the issue so far. I've added some of the environment variables using this table.

gdioni
New Contributor I
861 Views

Solution: I was missing a folder in PATH for environment variable.

 

specifically C:\Program Files (x86)\IntelSWTools\openvino\inference_engine\external\tbb\bin

View solution in original post

Iffa_Intel
Moderator
855 Views

Greetings,


Glad to know that you had solved the problem.

Hence, I shall close this thread.


Intel will no longer monitor this thread since this issue has been resolved. If you need any additional information from Intel, please submit a new question. 


Sincerely,

Iffa


Reply