Warm tip: This article is reproduced from serverfault.com, please click

Package OpenCV Dll to distribute C++ DLL

发布于 2018-06-07 14:43:32

I created on Visual Studio 2017 a DLL in C++ with a C wrapper and I am using the OpenCV library. I installed OpenCV on my computer, add the path of the .lib and .dll files in my project, and like this I am able to use my DLL in others programs. To be precise, I have now OpenCV on a folder C:\opencv\... and my visual studio solution on C:\MG\DLL\MyDll.sln.

But, in order to use it on another computer, I won't be able to install OpenCV so I have to find how to package the OpenCV library to distribute the correct files with my .dll file. Maybe I juste have to copy the .dll files of OpenCV in the same folder of my DLL ?

I don't know how to deal with this, because on internet I saw some people talking for example about CMake, others including some files in the project, ...

Moreover, I try to simulate this using a software in which I can add a C# plugin which use my C++ DLL. In this case, I rename the OpenCV folder to be sure the link with this folder is broken. If I copy the .dll files of OpenCV, the plugin is not functional anymore after renaming the installation folder of OpenCV.

Thank you in advance for sharing your experience/knowledge ;)

Questioner
Mathieu Gauquelin
Viewed
0
Mathieu Gauquelin 2018-06-08 16:04:44

I solved my problem.

Copying the .dll files is not enough. I needed to add to the PATH environment variable the folder where my DLL is with the software.

Next step, do the same thing with my Python program with doesn't recognize the openCV dll when I rename the installation folder.