[lug] OT: cc question
Stephen Queen
svq at peakpeak.com
Wed Dec 3 01:58:31 MST 2003
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