How to use sqrt() function with gcc?
- From: John <user@xxxxxxxx>
- Date: Fri, 04 Aug 2006 02:41:18 GMT
I'm trying to use the sqrt() function in Linux with GCC v3.3.6, compiling with this command:
$ gcc sourcefile.c
I get this error:
In function 'main': undefined reference to 'sqrt'
collect2: ld returned 1 exit status
Here is my source code:
#include <stdio.h>
#include <math.h>
main()
{
double num, sq_double;
scanf("%d", &num);
sq_double = sqrt(num);
}
What am I doing wrong? Is there something special I need to do to use the math.h functions?
.
- Follow-Ups:
- Re: How to use sqrt() function with gcc?
- From: Keith Thompson
- Re: How to use sqrt() function with gcc?
- From: Richard Heathfield
- Re: How to use sqrt() function with gcc?
- From: MrDev
- Re: How to use sqrt() function with gcc?
- Prev by Date: Re: gets() function generates strong warning message with gcc compiler
- Next by Date: Re: How to use sqrt() function with gcc?
- Previous by thread: something fishy here with stripnl()
- Next by thread: Re: How to use sqrt() function with gcc?
- Index(es):
Relevant Pages
|
|