How to dynamically link a library?
I am creating a dll that needs to use zlib
I am using VC++ 6.0 to create my DLL the dll needs to compress some data that's why I want to use zlib. I already compiled zlib1.dll and zlib.lib My understanding is if you are using zlib.lib you are statically linking therefore the functions/codes in zlib will be compiled within my project. If I use this code Code:
#include <zlib.h> Can someone please explain/correct me if my understanding to this matter is not right :) Is there any other way to not use "pragma comment(lib, "zlib1.lib")" |
It is obvious you are asking a Windows specific question. There is nothing wrong with that in this sub forum within LQ. But it might have helped to explicitly state that you want Windows specific help (to avoid confusing anyone who might otherwise try to give a Linux answer).
Quote:
As part of creating zlib1.dll you normally create an interface .lib file (is that zlib.lib?). Then you can use the interface .lib file at link time to indicate use of the .dll at load time. But, you might alternately or also have created a .lib file independently from the same source code as the .dll (is that what zlib.lib is?) such that the .lib used at link time is statically linking those functions instead of specifying use of the .dll at load time. Quote:
In Linux (and other POSIX and POSIX-like systems), you include a .lib file at link time to statically link the contents, or you include a .so file at link time to dynamically link the contents. If you have used or read about that sensible system, then the Microsoft kludge of using two different kinds of .lib may be confusing you. Quote:
But why don't you like that pragma? That seems a more robust way to manage the need for a library vs. specifying the function declarations (the .h file) far away from specifying the linkage to the lib. |
Quote:
Quote:
Quote:
|
Quote:
i was using vc7 in `02 the current vs express ( cmd) is free for win7 |
Quote:
Quote:
|
All times are GMT -5. The time now is 09:25 PM. |