-lm and -lm64 problems

Xianwen Chen xianwen.chen@gmail.com
Sun Dec 18 14:21:00 GMT 2011


Now it compiles just fine. Thank you very much Miles.

Xianwen

On Sun, Dec 18, 2011 at 7:17 AM, Miles Bader <miles@gnu.org> wrote:
>
> Xianwen Chen <xianwen.chen@gmail.com> writes:
> > 1) if I compile it as 'gcc -Wall -g -m64 -lm64 -o foo foo.c', it complains:
> > /usr/bin/ld: cannot find -lm64
> > collect2: ld returned 1 exit status
>
> You should use "-lm" (not "-lm64"), regardless of -m64 or -m32
> ... and:
>
> > 2) if I compile it as 'gcc -Wall -g -m64  -o foo foo.c', or 'gcc -Wall
> > -g -m32 -lm -o foo foo.c', it complains:
> > /dir/to/foo.c:15: undefined reference to `sqrt'
> > collect2: ld returned 1 exit status
>
> "-lm" should go _after_ anything that uses it.
>
> So:  gcc -Wall -g -m64 -o foo foo.c -lm
> or:  gcc -Wall -g -m32 -o foo foo.c -lm
>
> -Miles
>
> --
> Year, n. A period of three hundred and sixty-five disappointments.




--
Please notice that my previous email address v9@dr.com is no longer accessible.



More information about the Gcc-help mailing list