0

when you dynamically load a library at runtime using LoadLibrary in windows (C++), does it load into memory the same as the rest of your program, or might there be some overhead associated with calling functions referenced from that library? In other words, if you plan on making frequent calls to a function, will it be just as fast from the library as it would if you linked it into you program at compile-time, or do you lose some performance?

(This is not related to libraries that link to or against a program during compile-time via .lib/.a files.)

user980058
  • 511
  • 7
  • 18
  • possible duplicate of [Why/when is __declspec( dllimport ) not needed?](http://stackoverflow.com/questions/4489441/why-when-is-declspec-dllimport-not-needed) – Hans Passant Mar 24 '12 at 19:11

1 Answers1

1

Once dll is loaded and function pointer variable is initialized by GetProcAddress, there isn't any overhead in function call.

Steed
  • 1,292
  • 1
  • 14
  • 33
Luca Rocchi
  • 6,272
  • 1
  • 23
  • 23
  • by "there is any overhead" do you mean, 'there isn't any overhead'? Just double checking. – user980058 Mar 24 '12 at 19:06
  • .. yes i mean "there isn't any overhead" – Luca Rocchi Mar 24 '12 at 19:30
  • basically , function name is a pointer to the address in the memory where the binary code of the function starts...if you link static lib the compiler will map function name to the address... if you load the dll at runtime you initialize the pointer by GetProcAddress .. – Luca Rocchi Mar 24 '12 at 19:34
  • thx. yeah, I've used it a lot before but was worried about using it in a frame-by-frame rendering scenario. – user980058 Mar 24 '12 at 19:56