Loading a DLL that is not in the same directory as the executable
I have a DLL with a corresponding import library (.lib) that I want to load-time link into my executable. (ie not using the LoadLibrary() functions etc...) When I link in the import library by adding it to the linker command line, the resulting executable produces an error when it is run, saying that the program can't find the DLL file. When I copy the DLL file into the same folder as the executable though, everything works perfectly. I can understand why this is happening as at no point I 'told' the program where to find the DLL. How could I do this?
In other words, how can you use a DLL that is not in the same directory as the executable file?
I am using Microsoft Visual C++ 2003 to build the executable file and even though it's probably not important, I created the DLL myself and could rebuild it at any time.
Thank you in advance,