views:

46

answers:

3

I'm trying to statically compile something and I'm trying to get a handle on what all these dependencies are. I know that .dll files are for dynamically linked dependencies that will be required by the final output, but what are .a and .lib files and when do you need each of those?

A: 

Usually, .a is for static libraries under Linux whereas .lib are for the same but on Windows. But of course it is just a convention.

jldupont
+1  A: 

On Unix systems you have the .a files. These are simple archives of object files (.o).

On Windows, there are .lib files, which are quite the same thing, but for Windows instead of Unix.

An additional subtlety is that in order to link some code against a DLL (on Windows), you have to link against a .lib file which contains simple wrappers which invoke the DLL. On Unix system, traditionally, there is no need for such wrappers (the linker is smart enough to generate them on the fly).

Thomas Pornin
+1  A: 

.a is an archive of code: compiled but not linked. You would link statically with it during your program's final link step.

.lib can be either the same as .a, or a magical so-called "import library": a thin placeholder which causes you to require a .dll at runtime.

crazyscot
I'm compiling the QT framework with a .a OpenSSL library, but somehow my final executable produced by QT is still requiring an external OpenSSL dll in order to run. Do you have any idea how this could be the case given that I'm using a .a library?
Nantucket
How were the contents of the OpenSSL .a compiled?How are you linking your final executable?
crazyscot