what are the pros and cons of using a DLL?

2020-07-10 10:50发布

Windows still use DLLs and Mac programs seem to not use DLL at all. Are there benefits or disadvantages of using either technique?

If a program installation includes all the DLL it requires so that it will work 100% well, will it be the same as statically linking all the libraries?

9条回答
够拽才男人
2楼-- · 2020-07-10 11:34

From my point of view an shared component has some advantages that are somtimes realized as disadvantages.

  • shared component defines interfaces in your process. So you are forced to decide which components/interfaces are visible outside and which are hidden. This automatically defines which interface has to be stable and which does not have to be stable and can be refactored without affecting any code outside the component..
  • Memory administration in case of C++ and Windows must be well thought. So normally you should not handle memory outside of an dll that isn't freed in the same dll. If you do so your component may fail if: different runtimes or compiler version are used.

So I think that using shared coponents will help the software to get better organized.

查看更多
时光不老,我们不散
3楼-- · 2020-07-10 11:38

One big advantage of shared libraries (DLLs on Windows or .so on Unix) is that you can rebuild the library and its consumers separately while with static libraries you have to rebuild the library and then relink all the consumers which is very slow on Unix systems and not very fast on Windows.

查看更多
萌系小妹纸
4楼-- · 2020-07-10 11:39

MacOS X, like other flavours of Unix, use shared libraries, which are just another form of DLL.

And yes both are advantageous as the DLL or shared library code can be shared between multiple processes. It does this by the OS loading the DLL or shared library and mapping it into the virtual address space of the processes that use it.

查看更多
登录 后发表回答