c++ - Why does Implicit DLL Linking need relevant Lib file but Explicit Linking does not? -
in windows environment,
when tried link dll program explicitly (using loadlibrary),
- first need define function pointers according each function signature inside dll.
- then function addresses using 'getprocaddress' , assign them pointers.
when tried link dll program implicitly (using header file)
- first need relevant header file function signatures.
then needs relevant
lib
file generated dll.my questions are
- why implicitly linking need
lib
file well? - what information need retrieve 'lib' file cannot
dll
orheader file
? - if there question 2, how information retrieved when explicitly loading?
- why implicitly linking need
i've gone trough this question. cannnot understand worthy reason. please, explain in simple terms. thank you.
why implicitly linking need lib file too.
the .libs have import information of dll, can check information using dumpbin
command included in windows/visual studio sdk.
this link information of recv inside ws2_32.lib example:
version : 0 machine : 14c (x86) timedatestamp: 4907f6ed wed oct 29 01:38:53 2008 sizeofdata : 00000014 dll name : ws2_32.dll symbol name : _recv@16 type : code name type : ordinal ordinal : 16
you can check there ordinal , name inside ws2_32.dll (check says import dll).
what information need retrieve 'lib' file cannot dll or header file
in header file, there no information extract imports, them marked imports (__imp__name) when compiled, , when it's linked against .lib, resolves name:
- if it's inside .lib links against it.
- but if there information on external reference (dll), construct import inside import table it's loaded dinamically.
if there question 2, how information retrieve when explicit loading.
if explicit loading mean loadlibrary, telling @ runtime , not @ link time. pe loader search dll inside path , load dynamically. have other functions exported functions addresses.
if don't understand ask me, try playing dumpbin , read pe if want understand better.
Comments
Post a Comment