views:

1020

answers:

2

Ok, I'm just now learning how to add libraries to visual studio projects, but I'm running into a problem. I've gone to the project properties and added the correct path to the include header files I need and then I've added the correct path to the library files that I need. I'm not sure if this is redundant or not, but after that, I add the .lib file to the project as an "existing file." The program compiles fine, but when I try and debug it, it gives me an error saying that it can't find the correct .dll file for the library, even though the said .dll file is in the exact same folder as the .lib files that I've included in the project. Is there something I'm missing here or why is Visual Studio not finding the .dll file? Do I have to add a path directory for the .dll files like I did the include and library files in the project properties? Thanks for any help!

+2  A: 

The important thing is, that the DLL must be found when the program is run. There are many ways to achieve this. The easiest is to put the DLL file into the same directory as your compilation output (probably something like "debug/myprog.exe").

You don't have to add the .lib as existing file.

Ralph
+1  A: 

Another way is adding the path of the dll to the system PATH variable. There are some pitfalls here. If you have two .dll files with the same name, the system will try to load the .dll which comes first in the PATH variable. Also, if you keep adding paths to the PATH variable, your PATH variable will be quite a lot messy over time.

erelender