[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting 'undefined reference' errors during linking but I thinkI inc
Steve M. Robbins
Re: Getting 'undefined reference' errors during linking but I thinkI included all libraries?!?
Fri, 02 May 2003 15:19:07 -0400
On Fri, May 02, 2003 at 10:46:42AM -0700, address@hidden wrote:
> I was thinking about your comment that -L's must come before -l's but
> that it is /not/ necessary for -l's to go AFTER .o files and main()'s that
> call thosefunctions......
That's not what he said. The "-L" options may preceed the object files,
but the libraries themselves ("-l" options) definitely must follow
and must be in the correct order ...
> (I verified this is true by making a toy program that uses pow function
> and thentrying 'gcc -lm test.c' and 'gcc test.c -lm'. -> both worked.)
... unless your libraries are shared objects. In that case it doesn't
matter (at least on linux). Probably libm is shared. Try this again
using "gcc -static -lm test.c".