Graviton
Graviton

Reputation: 83244

Difference between *.a and *.dll on Windows

What is the difference between *.a and *.dll on Windows? From what I understand one can package all the *.o files into a *.a, which is a distributable that other application can use, on Linux.

But what are the difference between *.a and *.dll? Are they interchangeable? If my application needs to link to *.a, can I link it to *.dll as a substitute?

Upvotes: 5

Views: 3406

Answers (3)

futureelite7
futureelite7

Reputation: 11502

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

Upvotes: 1

Timo Geusch
Timo Geusch

Reputation: 24341

Aside: There is no defined *.a format with plain Windows development tools, unless you use a Linux-based tool chain. You're presumably referring to a static library, aka .lib in Windows.

A DLL is the equivalent of a shared library (*.so) on Unix and no, you normally can't link to a shared library/dll if the linker expects you to link against a static library.

Upvotes: 7

jdehaan
jdehaan

Reputation: 19928

Under Linux with gcc you will see two kind of files the archives *.a (used to provide a set of functions to link in statically) and *.so, so called shared object library (to link dynamically). Their equivalent under windows for most compilers are *.lib and *.dll.

So *.a and *.dll are not interchangeable at all. Moreover you have under windows the dilemma that a *.lib can be used for both linking statically and dynamically (with fixed addresses). Another way is to bind fully dynamically with GetProcAddress but that has to overhead of creating a wrapper, might be what you need if you want to make the dlls work for different versions.

You may recognize the static libs at their size, they are huge in comparison to the libs used to link dynamically. In my projects I really often go the way with GetProcAddress as I like the ability to just drop in the fresh new DLLs for older applications without linking everything again.

Upvotes: 0

Related Questions