Now it compiles just fine. Thank you very much Miles. Xianwen On Sun, Dec 18, 2011 at 7:17 AM, Miles Bader <miles@xxxxxxx> wrote: > > Xianwen Chen <xianwen.chen@xxxxxxxxx> 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@xxxxxx is no longer accessible.