Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 758
Netwave Avatar asked Nov 18 '13 10:11

Netwave


People also ask

How do you make a copy of a DLL to the output directory in Visual Studio?

Use a post-build action in your project, and add the commands to copy the offending DLL. The post-build action are written as a batch script. The output directory can be referenced as $(OutDir) . The project directory is available as $(ProjDir) .


1 Answers

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.

like image 158
Hans Passant Avatar answered Nov 15 '22 14:11

Hans Passant