Difference between * .a and * .dll in Windows

What is the difference between *.a and *.dll on Windows? From what I understand, you can pack all * .o files into *.a , which can be used for other Linux applications.

But what is the difference between *.a and *.dll ? Are they interchangeable? If my application should reference *.a , can I link it to *.dll as a replacement?

+4
source share
3 answers

In addition: there is no specific * .a format with conventional Windows development tools unless you use the Linux-based toolchain. You are probably referencing a static library, otherwise .lib on Windows.

A DLL is the equivalent of a shared library (* .so) on Unix, and no, you usually cannot reference the / dll shared library if the linker expects you to reference the static library.

+4
source

Seeing that * .a are static Linux libraries, they are not at all interchangeable with Windows.dll (dynamic linking libraries), since they have completely different formats. If your application needs to link to the .a you created, you will need to recompile the source code that generated your old linux library (if possible) into the Windows static library (.lib), and compile your code against this.

+1
source

On Linux with gcc, you will see two types of files: *.a archives (used to provide a set of functions for linking statically) and *.so , the so-called shared object library (for dynamic linking). Their *.lib equivalent for most compilers is *.lib and *.dll .

So *.a and *.dll are not interchangeable. In addition, you have a problem under Windows that *.lib can be used to bind statically and dynamically (with fixed addresses). Another way is to fully associate GetProcAddress dynamically with GetProcAddress , but in order to work with dll for different versions, it may require overhead to create a wrapper.

You can recognize static libs by their size, they are huge compared to the libs used for dynamic communications. In my projects, I really often get GetProcAddress , because I like the ability to just add new DLLs for old applications, without linking everything again.

0
source

Source: https://habr.com/ru/post/1299420/


All Articles