Problem with math.h
I should be bashed to death for not being able to do this :) ...I just started learning C, I am using gcc 3.2.3 on a linux box. This is the code I wrote, which finds prime numbers below 100:
Code:
#include <stdio.h> Code:
bash-2.05b$ gcc primo.c -o primo Thanks |
Use gcc -lm -o myprog myprog.c
The "-lm" invokes linking of the math library. |
Re: Problem with math.h
Quote:
Assuming you c-file is called "prime.c", and you want the executable be called "prime", compile with this command line Code:
gcc -lm -o prime prime.c You'll also see another error, because you forgot to pass the variable i to the printf statement. Change the line to: Code:
printf ("%d\n", i); Compile with this to make the compiler report all possible warnings: Code:
gcc -Wall -pedantic -lm -o prime prime.c |
Thank you...so it was a problem about compiler knowledge :)
|
To be pedantically precise: it was a problem about linking knowledge :-)
|
All times are GMT -5. The time now is 07:42 AM. |