Consider the following short C
program:
#include <math.h>
#include <stdio.h>
#define K 20
// int K = 20;
int main() {
printf("%f\n", sqrt(K));
}
This program, as given, compiles with gcc Foo.c
, and produces correct output.
However, if we comment out the #define
line, and comment in the int K = 20
line, then we get a compile-time error of undefined reference to sqrt'
, which can only be fixed by compiling with gcc Foo.c -lm
.
I am on gcc 4.7.3
on Ubuntu 13.04
.