cc -c main.c cc -c blah.c cc main.o -o example [doesn't work] cc main.o blah.o -o example [works]
static int foo;
#ifndef FOO_H_INC #define FOO_H_INC #include "foo.h" ... #endif /* FOO_H_INC */
cc -c main.c cc -c blah.c cc main.o blah.o -o example
| ar -r archive files... | inserts files into archive with replacement |
| ar -t archive | prints table of archive contents |
ranlib archiveor
ar -s archive
Creating the library
cc -c bar.c cc -c blah.c ar -r libblah.a bar.o blah.o ar -t libblah.a [shows contents] ar -s libblah.a [or ranlib]Using the library
cc -c main.c cc main.o -L. -lblah -o example