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"?
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.)
The use of DLLs helps promote modularization of code, code reuse, efficient memory usage, and reduced disk space. So, the operating system and the programs load faster, run faster, and take less disk space on the computer. When a program uses a DLL, an issue that is called dependency may cause the program not to run.
Every process that loads the DLL maps it into its virtual address space. After the process loads the DLL into its virtual address, it can call the exported DLL functions. The system maintains a per-process reference count for each DLL. When a thread loads the DLL, the reference count is incremented by one.
In Windows, a dynamic-link library (DLL) is a kind of executable file that acts as a shared library of functions and resources. Dynamic linking is an operating system capability. It enables an executable to call functions or use resources stored in a separate file.
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.
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.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With