Reputation: 393
I'm new C++, I have a dll file called DiceInvaders.dll
, in my project, I need to use this library, I'm using visual c++ 2010, I set the Linker
Input
as DiceInvaders.lib
and DiceInvaders.dll
, I also copied this dll file to my porject directory, I always got error in this line of code:
m_lib = LoadLibrary("DiceInvaders.dll");
assert(m_lib);
The error is assertion failure. How should I solve this? Thank you in advance.
Upvotes: 1
Views: 10357
Reputation: 20063
First you cannot pass the DLL
to the linker like you are, it is not a file type that the linker recognizes and cannot be linked that way. When you create the Diceinvaters.dll
file the linker will create an import library with the same filename and the extension .lib
. It appears this is already being done. That is the library file you should pass to the linker when building any application that uses it.
Second, the Diceinvaders.dll
file must be accessible in the DLL search path. This varies slightly depending on which version of Windows you are using but is generally something like the following
Placing the DLL in your project directory is not going to be enough. Instead you should place it in the same directory as the EXE
file(s) that have a dependency on it.
Upvotes: 7