Alex Rivera | Logout

What's the difference between .lib and .a files?

Asked 2010-02-25T21:55:34.453
63

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?

Edit
Report

1 Answer

44

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).

answered 2010-02-25T22:01:13.923

Your Answer