A static library is a collection of one or more object files with an index for quick search. There are some minor differences in how the compiler handles them. You refer to the object file as follows:
gcc f1.o f2.o -o myexe
with libraries you can also do this:
gcc f1.o libf2.a -o myexe
or you can use the shortened version:
gcc d1.o -lf2 -L. -o myexe
In addition, gcc will ALWAYS link .o files, but it will only look for libraries and reference them if there are still undefined names.
Neil Butterworth May 30 '11 at 14:27 2011-05-30 14:27
source share