[lug] OT: cc question
Chan Kar Heng
karheng at softhome.net
Wed Dec 3 08:06:30 MST 2003
I'm answering this offhand... try this instead:
cc simple.c -lm
At 2003-12-03 04:58 PM, you wrote:
>If I enter the following simple program
>
>#include <math.h>
>#include <stdio.h>
>
>int main()
>{
> double results;
>
> results=sqrt(4);
> printf ("%f\n", results);
>
> return 0;
>}
>
>and compile it with the following on the command line
>
>cc simple.c
>
>I get the following error
>
>/tmp/cc40XqaS.o(.text+0x1b): In function `main':
>: undefined reference to `sqrt'
>collect2: ld returned 1 exit status
>
>If I then use the following command to compile it, it works correctly.
>cc simple.c -O2
>
>This is true on debian and slackware. Does anyone know of an explaination?
More information about the LUG
mailing list