From http://www.adp-gmbh.ch/cpp/gcc/create_lib.html:
Note: the library must start with the three letters
liband have the suffix.a.
Is this an operating system convention, or a gcc/ar quirk? Xcode seems to be able to create libraries without the prefix. What’s it doing differently?
You can name a library whatever you want, but if you want gcc’s
-lflag to find the right one, you need to name it the way that link describes. For example:Will compile
myapp.c, link the resulting object withlibm.a, and output an executable calledmyapp. These days, there might be a more complicated search path involving dynamic library names, etc., but you should get the basic idea from this example.From the gcc man page: