Reputation: 1415
I have a third party library (say, tp.lib) and the third party dll (say, tp.dll) which I need to use in my C++ project (my project makes a dll, lets call it my.dll).
I have included the library with the #pragma comment(lib, "libraryname") in the header file and also included the path of the library file in the configurationproperties->linker->additional library directories in my C++ Visual Studio project.
The code compiles and links okay. but fails to execute. When I used depends to check if i am missing something, I observed that the tp.dll is not found. The tp.dll resides in the same library folder where the tp.lib resides.
What should I do so that tp.dll gets included to my.dll?
Upvotes: 0
Views: 1446
Reputation: 25505
The search path at runtime does not include the folder where you put the lib library, so putting the DLL with the lib is not enabling the OS to find it at runtime. You can add that to the path, or move the DLL. The list of search precedence is on MSDN.
Upvotes: 0
Reputation: 178369
DLLs have a different search path. Quote below from docs:
With both implicit and explicit linking, Windows first searches for "known DLLs", such as Kernel32.dll and User32.dll. Windows then searches for the DLLs in the following sequence:
The directory where the executable module for the current process is located.
The current directory.
The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
The directories listed in the PATH environment variable.
Note The LIBPATH environment variable is not used.
Upvotes: 1
Reputation: 14591
You can't "include the dll into another dll". You need to either deploy them together, or put the dependency dll in a place where Windows will find it.
Upvotes: 0