# Re: [*] about gcc

On 7 Feb 2000 01:09:00 +0800, maths@21cn.com (=?ISO-8859-1?Q?=D5=C5=CF=FE=C0=DA@murphy.debian.org) was crying out from somewhere
about: [*] about gcc
maths> hello everybody:
maths>
maths> i am using debian 2.1r4, i install it use deselect's preselect "scientific
maths> workstation". i found my gcc doesn't allow me to use "sqrt", for example:
maths>
maths> this is a c file: a.c
maths>
maths> #include "stdio.h"
maths> #include "math.h"
maths> main(){
maths> printf("%f\n",sqrt(2));
maths> }
maths>
maths> and execute "cc a.c"
maths>
maths> i get:
maths> /tmp/ccc00242: In function 'main':
maths> /tmp/ccc00242(.text+0xb): undefined reference to 'sqrt'
maths>
maths> so i had to use g++ instead, and it worked!
maths>
maths> i had use this gcc to campile some math software such as "pari", "simath","rlab"...and
maths> it work very well, not any error reported.
maths>
maths> what is the problem?
maths>
you need to do
gcc -lm
to link the maths library.
Don't ask me why.
---------------------------------------------------------------------------
Junichi Uekawa, a.k.a. dancer
a member of the Dept. of Knowledge Engineering and Computer Science,
Doshisha University.
... I pronounce Linux as Day-bee-enne

**Reply to:**

**References**:
**[*] about gcc**
*From:* ÕÅÏþÀÚ@murphy.debian.org, [zhangxiaolei]@murphy.debian.org <maths@21cn.com>