No need to sell DLLs to me -- I have worked extensively with them in assorted guises inc. NSAPI plugins, Microsoft Office Add-ins, and in-process COM servers!
|is there a way to use a Pragma comment line to import a DLL file, rather than a LIB file? |
The Visual Studio C++ linker needs an import
library to build your app if you want to use implicit dynamic linking (when the DLL is loaded automatically when the exe is launched) rather than explicit runtime dynamic linking (where you have to load using LoadLibrary() and resolve the function addresses with GetProcAddress().)
An import library contains just the information the linker need to resolve the entry points, not the complete implementation like a static library. So linking to it won't bulk out or otherwise "contaminate" your exe.
When you build a DLL with Visual Studio you should end up with a DLL plus it's import library. And if you obtain a DLL from a 3rd party for use with apps you build yourself you should also get the associated header file(s) and import library.
If you do not already have the required import library it is possible to create one:
How To Create 32-bit Import Libraries Without .OBJs or Source
(the article is about 32-bit DLLs, but I don't see an obvious reason why the same approach couldn't be applied to 64-bit DLLs.)
PS I recently learnt that the MINGW version of the GCC linker can use a DLL (if the DLL in unstripped) to resolved entry points as link time. But it doesn't understand #pragma lib, so it's a moot point.