To use a library, use the -l switch on your linker command line. The string immediately following the -l is the unique part of the library filename that the linker will link in. For example, if you use:


this will expand to the library filename:


which happens to be the math library included in avr-libc.

If you use this on your linker command line:


then the linker will look for a library called:


This is why naming your library is so important when you create it!

The linker will search libraries in the order that they appear on the command line. Whichever function is found first that matches the undefined reference, it will be linked in.

There are also command line switches that tell GCC which directory to look in (-L) for the libraries that are specified to be linke in with -l.

See the GNU Binutils manual for more information on the GNU linker (ld) program.