It is always safer to put -lx after the list of sources and objects to insure that libraries are searched in the correct order.