9

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Netwave
  • 40,134
  • 6
  • 50
  • 93
  • You can try adding them as **resources** – Vahid Nateghi Nov 18 '13 at 10:08
  • In the **properties** of your project, there is a section named **resources**, I'm gonna add it as an answer – Vahid Nateghi Nov 18 '13 at 10:12
  • **Which** dll's are we talking about? What DLL do you need in the debug/release folders? Are these supposed to be built by your project, or are these the regular Qt DLLs? – MSalters Nov 18 '13 at 10:42
  • The regular Qt Dlls ones and the msvc ones too. – Netwave Nov 18 '13 at 10:46
  • add a post-build event in project properties that copy dll's whenerer you want. Use environment variables in order to remain consistent. – Jepessen Nov 18 '13 at 11:39
  • 1
    possible duplicate of [how to make visual studio copy dll to output directory?](http://stackoverflow.com/questions/1776060/how-to-make-visual-studio-copy-dll-to-output-directory) – user Mar 09 '14 at 22:55

2 Answers2

26

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.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
-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.

Vahid Nateghi
  • 576
  • 5
  • 14
  • I've just get this warning when compiling: RCC : warning : No resources in 'C:\Users\Netwave\Documents\Visual Studio 2012\Projects\Shutdowner\Shutdowner\shutdowner.qrc' – Netwave Nov 18 '13 at 10:35
  • Ok, I've been investigating, it should be between "Manifest Tool" and "XML Document Generator", but there is no such opction in mine... :S – Netwave Nov 18 '13 at 10:45
  • @DanielSanchez: In your solution explorer, right click on your project name and at the end of the list you will see `Properties` – Vahid Nateghi Nov 18 '13 at 10:50
  • ow, try adding a new item, then add a resource file to the project – Vahid Nateghi Nov 18 '13 at 10:54