This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static link errors with libm


Jaap Eldering <eldering@phys.uu.nl> writes:

> On Sat, Aug 14, 2004 at 02:04:48PM -0400, Ishwar Rattan wrote:
> > Try -lm as the last command-line argument to gcc
> > -ishwar
> 
> Ok, this works. Thanks!
> 
> But why does it have to be last? I'd suppose only the order with respect
> to -static might matter.

Object files and libraries are searched from left-to-right so the
sin() function is not picked up when -lm appears first.

In C, the math library is separate from the main standard library for
historical reasons. In C++ you don't need a separate -lm so the g++
command works on its own.

-- 
Brian Gough

Network Theory Ltd,
Publishing "An Introduction to GCC" --- http://network-theory.co.uk/gcc/intro/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]