.o files are objects. This is the result of the compiler and the input for the linker / librarian.
.a files are archives. They are groups of objects or static libraries, and are also entered into the linker.
Additional content
I did not notice part of the "examples" of your question. Typically, you will use a makefile to create static libraries.
AR = ar CC = gcc objects := hello.o world.o libby.a: $(objects) $(AR) rcu $@ $(objects) %.o: %.c $(CC) $(CFLAGS) -c $< -o $@
This will compile hello.c and world.c into objects and then archive them into a library. Depending on the platform, you may also need to run a utility called ranlib to create a table of contents in the archive.
An interesting note: .a files are files with technical archives, not libraries. They are similar to uncompressed zip files, although they use a much older file format. A table of contents created by utilities such as ranlib is what makes an archive a library. Java archive files ( .jar ) are similar in that they are zip files that have some special directory structures created by the Java archiver.
D.Shawley Mar 17 '09 at 15:24 2009-03-17 15:24
source share