The value of building a dll as an export library

What is the point of building a dll as an export library? I was just looking for it. I found a dynamic link library. Can someone explain what the dll really is? and why do we need to add this operator to the dll file

extern "c" _declspec(dllexport) 

I have studied static and shared libraries, but I'm not sure why we are going for DLL files. I studied .dll, used for runtime. But can you help me and give me more information. thanks in advance

+4
source share
1 answer

Perhaps in my comments I was a little harsh. I am not an authority on the DLL, but I have a little knowledge about them, so I will try to give a short explanation.

The difference between static and shared libraries should be easily found in a web search, but basically the code in the static library is included in the final executable file, therefore, after the linking step, the actual library file no longer needs to run the program; on the other hand, the code in the shared library is not included in the main program - the two parts remain separate, so a shared library (called dll on windows) will be needed every time the program is launched.

"Building a dll as an export library" is a slightly confusing term. I had not heard about this before, and during a short search you could find it only on the cygwin page, which you could read, given your original tags. A DLL can export some or all of its functions and data. Export means that they are available for other dll programs and libraries. What names can be exported can be controlled in various ways. One of them is the insertion of _declspec(dllexport) into a function declaration. Another way is to use a definition file with an export section.

When creating a dll, an import library can be created. This is a file that can then be used to create an executable file that uses the DLL at the build stage to tell which names are exported from the DLL, so the program knows how to resolve links to these functions; in other words: how to import them. (This is not always necessary. Many linkers allow you to directly contact the dll itself, thereby eliminating the need for an import library.)

I understand that this can be confusing, but try to find a tutorial and a few small examples to see how it works and play a little with it.

+1
source

All Articles