How can I make Visual Studio copy the required .dll files into the release folder?

守給你的承諾、 提交于 2019-12-18 04:48:15

问题


I'm using Visual Studio 2012 with C++, developing a Qt application.

I'm able to compile it and debug it, but, somehow, no .dll file is in the Debug or Release folder. I've tried some of other posts solutions, but none worked.

So, how can I make Visual Studio copy the required .dll files into the release folder?

I think it should be an option somewhere. I'm just starting to think about copying it handmade.


回答1:


Too much bad advice, a DLL cannot be a resource. Windows demands that code is stored in a separate executable file with a proper PE32 header. Which permits it to create a memory-mapped file to map the file content into memory, allowing the code to be shared by multiple processes and keeping it out of the paging file. And to relocate the code when the DLL's base address is already in use.

Simply use Project + Properties, Build events, Post-Build Event to xcopy the DLLs. Arbitrarily, if you stored the needed DLLs in the "dlls" subdirectory of your project then this command will get them copied, only when necessary:

 xcopy /d /y "$(ProjectDir)dlls\*.*" "$(OutDir)"

Use it both in the Debug and Release configuration so you'll debug exactly what you'll ship.




回答2:


Add your .dll files as resources to your project. In this way your .dll files will be in a resources folder in you project.

Try Add Item... -> New Item... and add a resource (.qrc) file to the project and add the .dll files to that.



来源:https://stackoverflow.com/questions/20045015/how-can-i-make-visual-studio-copy-the-required-dll-files-into-the-release-folde

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!