Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't Visual Studio find my DLL? [duplicate]

In Visual Studio 2010, under VC++ Directories > Executable Directories, I have specified the path to glew32d.dll. However, when I run the executable, it still complains.

On the other hand, if I copy the DLL into the local folder and run the executable then, it doesn't complain.

Can someone please tell me how to fix this? Also, why is Visual Studio not recognizing that path?

Update Scenario: I currently use a template project which I use as a starter code for a lot of my projects. This template depends on glew32d.dll. I usually store all dependent dlls in a common bin folder. I was hoping to reference this folder and Visual studio could read the dlls from there, instead of me having to copy the dlls everytime. What would be a good way to handle this?

like image 998
brainydexter Avatar asked Feb 10 '11 05:02

brainydexter


People also ask

Why are my DLL files missing?

Sometimes, you'll get a missing . dll file error while using hardware such as a printer. This error can be due to an older version of the driver that is not compatible with the updated . dll file, so the printer is looking for a wrong .

Where are DLL files located in Visual Studio?

Dll files are located in C:\Windows\System32.


2 Answers

Specifying the path to the DLL file in your project's settings does not ensure that your application will find the DLL at run-time. You only told Visual Studio how to find the files it needs. That has nothing to do with how the program finds what it needs, once built.

Placing the DLL file into the same folder as the executable is by far the simplest solution. That's the default search path for dependencies, so you won't need to do anything special if you go that route.
To avoid having to do this manually each time, you can create a Post-Build Event for your project that will automatically copy the DLL into the appropriate directory after a build completes.

Alternatively, you could deploy the DLL to the Windows side-by-side cache, and add a manifest to your application that specifies the location.

like image 158
Cody Gray Avatar answered Sep 19 '22 21:09

Cody Gray


I've experienced same problem with same lib, found a solution here on SO:

Search MSDN for "How to: Set Environment Variables for Projects". (It's Project>Properties>Configuration Properties>Debugging "Environment" and "Merge Environment" properties for those who are in a rush.)

The syntax is NAME=VALUE and macros can be used (for example, $(OutDir)).

For example, to prepend C:\Windows\Temp to the PATH:

PATH=C:\WINDOWS\Temp;%PATH% 

Similarly, to append $(TargetDir)\DLLS to the PATH:

PATH=%PATH%;$(TargetDir)\DLLS 

(answered by Multicollinearity here: How do I set a path in visual studio?

like image 36
Oleg Avatar answered Sep 20 '22 21:09

Oleg