I'm getting this error message from gcc when trying to compile my code...

# gcc project7.c

/tmp/cc4pGFvN.o(.text+0xbb): In function `isPrime':

: undefined reference to `sqrt'

collect2: ld returned 1 exit status

I can't find anything wrong with the source...at least nothing obvious.

It doesn't seem to like the sqrt() function, yet as you can see I've included the math.h library.

Code:#include <stdio.h> #include <math.h> int isPrime ( int number ); int main() { int primeFound = 0; int number; for ( number = 3 ; number <= 10000 ; number += 2 ) { if ( isPrime ( number ) ) { primeFound++; printf ("%7d" , number); if ( primeFound % 5 == 0 ) printf("\n"); } } printf ("\nPrimes found %d\n" , primeFound); return 0; } int isPrime ( int number ) { int n; for ( n = 3 ; n <= sqrt(number) ; n += 2 ) { if ( number % n == 0 ) return 0; } return 1; }