How do I set the path to a DLL file in Visual Studio?
Solution 1:
- Go to project properties (Alt+F7)
- Under Debugging, look to the right
- There's an Environment field.
- Add your relative path there (relative to vcproj folder) i.e. ..\some-framework\lib by appending
PATH=%PATH%;$(ProjectDir)\some-framework\lib
or prepending to the pathPATH=C:\some-framework\lib;%PATH%
- Hit F5 (debug) again and it should work.
Solution 2:
Go through project properties -> Reference Paths
Then add folder with DLL's
Solution 3:
The search path that the loader uses when you call LoadLibrary() can be altered by using the SetDllDirectory() function. So you could just call this and add the path to your dependency before you load it.
See also DLL Search Order.
Solution 4:
Another possibility would be to set the Working Directory
under the debugging options to be the directory that has that DLL.
Edit: I was going to mention using a batch file to start Visual Studio (and set the PATH variable in the batch file). So then did a bit of searching and see that this exact same question was asked not long ago in this post. The answer suggests the batch file option as well as project settings that apparently may do the job (I did not test it).