问题描述
我在Visual Studio 2017上使用C包装器在C ++中创建了一个DLL,并且正在使用 OpenCV
库.我在计算机上安装了 OpenCV
,在项目中添加了 .lib
和 .dll
文件的路径,这样我就可以在其他程序中使用我的DLL.确切地说,我现在在文件夹 C:\ opencv \ ...
上有OpenCV,而我的Visual Studio解决方案位于 C:\ MG \ DLL \ MyDll.sln
上.
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
.
但是,为了在另一台计算机上使用它,我将无法安装 OpenCV
,因此我必须找到如何打包 OpenCV
库以进行分发我的 .dll
文件中包含正确的文件.也许我只需要将 OpenCV
的 .dll
文件复制到我DLL的同一文件夹中?
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 ?
我不知道该如何处理,因为在互联网上,我看到一些人谈论例如 CMake
,其他人包括项目中的某些文件,...
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, ...
此外,我尝试使用一种软件进行模拟,在该软件中,我可以添加一个使用C ++ DLL的C#插件.在这种情况下,我重命名 OpenCV
文件夹,以确保与此文件夹的链接断开.如果我复制 OpenCV
的 .dll
文件,则在重命名 OpenCV
的安装文件夹后,该插件不再起作用.
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 ;)
推荐答案
我解决了我的问题.
仅复制 .dll
文件是不够的.我需要在DLL环境变量中添加DLL所在的文件夹.
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.
下一步,对我的Python程序执行相同的操作,但在重命名安装文件夹时无法识别openCV dll.
Next step, do the same thing with my Python program with doesn't recognize the openCV dll when I rename the installation folder.
这篇关于打包OpenCV Dll以分发C ++ DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!