2

To reference an external DLL in VS2015, I can add correctly include paths and additional dependencies to .lib file

If I copy that dll to the place where I am trying to link it from I can successfully run that application.

However, I do not want to copy each DLL into my project directory.

Is there a way to reference a DLL by its full path instead?

arcyqwerty
  • 10,325
  • 4
  • 47
  • 84
Artur
  • 181
  • 1
  • 9
  • If you right-click on the project in the Solution Explorer and select Add Reference and choose the .DLL, wherever it is stored, and then you run the application, does that DLL get copied in the project folder? – dspfnder Oct 23 '15 at 12:45
  • @dspfnder The problem is that the dialog which opens after selecting Add reference doesn't allow me to browse. – Artur Oct 23 '15 at 12:54
  • Programmers never repeat the same triviality over and over again. They let a machine do it. You are asking for the wrong solution. – Hans Passant Oct 23 '15 at 13:07
  • @HansPassant Hi, Couldn't agree more with you. That's the exact reason I want to know how to do it, so I don't have to repeat it over and over again. Would you know how to solve this problem? – Artur Oct 23 '15 at 13:09
  • I would know, but I can't tell you because you are asking for the wrong solution. Just ask Google, type "copy dll in post build event" in the query box. – Hans Passant Oct 23 '15 at 13:11
  • @Artur, you should add the project with the .DLL to your solution first and after adding the project to the solution, you will be able to browse to it. – dspfnder Oct 23 '15 at 13:12
  • @dspfnder Hi, but the whole point is that I do not want to manually and literally adding that dll into my project. I only want to give a path from VS to the folder that dll is in. Is this possible to do in VS2015? – Artur Oct 23 '15 at 13:14
  • @HansPassant Would you mind and elaborate how am I asking about the wrong solution? Surely it is sensible to simply add/give a path to dir where the dll is rather that copying it (that dll file) to a project directory each time I'm starting new project? – Artur Oct 23 '15 at 13:17
  • The only sensible way to do it is by debugging and testing your code the *exact* same way it is going to run on your user's machine. And every user is like you and me, we absolutely hate anybody messing with the PATH or sprinkling executable files in places they don't belong. There's only one good place. – Hans Passant Oct 23 '15 at 13:27
  • @HansPassant I don't think you understood me correctly. I am not talking about changing user's PATH. The only thing I am talking about is to add reference in my project file to that dll so I don't have to copy it every time. In a same way I'm adding include directories, lib directories from VS and I don't copy them each time I'm creating new project/solution. – Artur Oct 23 '15 at 13:42
  • You are asking for a pony, it doesn't exist. And doesn't have to considering the alternative is so dead simple. – Hans Passant Oct 23 '15 at 13:47
  • @HansPassant OK, I get it, thanks, at least I know now. – Artur Oct 23 '15 at 13:52
  • @Mogsdad thanks, it is exactly what I was asking for – Artur Dec 10 '15 at 08:22
  • so as @Mogsdad shown, the pony I'm asking for indeed exists, and happens to be very well and sound. – Artur Dec 10 '15 at 08:23

0 Answers0