include dlls in visual studio c++ 2008

2019-07-06 17:33发布

Is there a way to include dlls in a project so that I don'thave to put those dlls in the same folder with my executable after compiling. This way I could just compile my project with them. Is this a possibility and if yes could someone guide me.

My project is an opencv project and there are many dlls that I would have to include in the folder, and I don't know whether they are .NET assemblies or not, since I read an other post which said that it can be done with .NET assembly dlls.

3条回答
Viruses.
2楼-- · 2019-07-06 17:54

You can't directly do it with DLL's. "DLL" stands for "Dynamically Linked Library", which means they're not statically linked libraries. And it's the latter kind of library which is "included" (linked in) when you're creating your executable. DLL's are included only at the moment when you run the EXE.

You can check the CV documentation so see how you get a static library version of CV.

查看更多
Evening l夕情丶
3楼-- · 2019-07-06 17:54

The dlls are designed to be dynamically linked - that is they are loaded with your program when it runs.

They don't have to be in the same folder as your app, just somewhere on the path, so you only need one copy of the opencv dlls for all the opencv based programs on your machine.

edit: You can build openCV to use static libraries but it's not recommended, you still have external dependancies such as ffmpeg and the image format libs, and Qt if you used that.

On windows you should probably build an installer which can bundle the exe and dlls. Windows otherwise it will warn every time it runs the app innosetup is one of the simplest.

查看更多
一夜七次
4楼-- · 2019-07-06 17:56

I understand that what you wish to do is to deploy your exe file along with its dependencies (dlls), but you also want it to be configured in the project. You can configure your project to use static libraries instead and you don't have to worry about distributing your DLLs because they are already built into the exe.

If you wish to use DLLs because you do not want to bloat your exe then your code will have to implement its loading, i.e. calling LoadLibrary function and the necessary calls to the specific export functions. Once your code has implemented the loading of the DLLs then you can deploy them the way you described.

查看更多
登录 后发表回答