From your phrasing it is pretty clear you are using Dev Studio some or other version.
In order to implicitly link against a dll, VC++ needs a .lib file, no questions. Without a .lib you can only explicitly load the dll using LoadLibrary and GetProcAddress.
Fortunately import libraries contain nothing other than the dll's exported symbols, so it is perfectly legitimate to simply create a dll project in VC++ that exports the identical symbols, build it, and then use the resulting .lib file to access the target dll.
The trick really is, getting the symbols right: Depending on how the original dll was created there might be some decoration to deal with.
"Initialize" could be exported from a dll in several ways when viewed with dependencywalker
- "Initialize" - was either exported via a .DEF file, or via
extern "C" __declspec(dllexport) int __cdecl Initialize(...
- "_Initalize@16" - was exported using:
extern "C" __declspec(dllexport) int __stdcall Initialize(...
- ?Initialize@@YAHPADOH@Z" - `__declspec(dllexport) int Initialize(char*,char*,int);
- ?Initialize@@YGHPADOH@Z" - `__declspec(dllexport) int __stdcall Initialize(char*,char*,int);
The problem really is the first case - if the calling convention isn't __cdecl (and most dll api's are actually __stdcall - all windows dlls are __stdcall) then you must use a .def file to export the undecorated names.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…