Stop Undefined References
There are many reasons why you might receive undefined references. The typical reason is that you have not specified an appropriate library or your command line order is incorrect. In order for a library to resolve references the dependency for the library must precede the library in the command line order.
gcc -o foo -L/path/to/mylib bar.o -lbaz
In the example you are building program foo that uses object file bar.o that has depencies to references in libbaz.a that is stored in the /path/to/mylib directory. If you have say three libraries with circular dependencies you must specify the libraries mutltiple times until there are no more undefined references.
gcc -o foo -L/path/to/libraries bar.o -lbaz -lfiz -ljaz -lbaz
In the example baz has dependencies on fiz and jaz, fiz has depencies on jaz and baz and jaz may have dependencies on baz.