Reputation: 6149
First of all, I use user-defined header and corresponding cpp
file. Then I include and so on. If I would switch to DLL, would the execution speed of the code be retarded?
Secondly, I know that in "DLL", "D" represents "dynamic" however, my friend said that there are two ways to use them: Statically and dynamically. If it is dynamic already, what we have to do with "static"?
Upvotes: 7
Views: 6163
Reputation: 19384
Unless the function is very small (so it gets inlined otherwise), using a DLL has no difference whatsoever on the performance (aside from the fact that loading a DLL does increase the startup time of your application.) Large, performance-critical applications use DLLs (for instance the Intel Math library.) There are minor penalties if the compiler cannot do whole-program optimization, but these are very small differences which usually don't matter.
Regarding static/dynamic: I assume he means that you can link against a DLL the normal way (by using an import library), which forces it to be always loaded or load it dynamically at run-time (using LoadLibrary
and dlopen
.) No performance difference there, but using LoadLibrary
allows you to delay loading the library until actually needed.
Upvotes: 14
Reputation: 12547
Productivity shouldn't regress, as far as calling function from dll in general similar to local function call.
Two types of libs exists:
exe
, oppositely dynamic lib allows to separate code from executable to shared library, that code will be loaded dynamically.Upvotes: 2