Subject: Re: what's up with the gcc compiler (NetBSD 1.4.1)?
To: village idiot <village_ldi0t@yahoo.com>
From: David S. <davids@idiom.com>
List: netbsd-help
Date: 04/24/2002 12:40:34
>
> First I compile my module, which links to several
> other modules. I get some error messages, which is not
> too seldom for me ;-) Then I fix this errors, or so I
> think. Then I do a make clean, to do it all over. But
> now, when I run make, I get these weird error
> messages:
>
> "Undefined symbol [...] referenced from text segment"
You're probably using a function from a library, but not linking
against that library when you build your executable. For example,
on my 1.5.2 box, if I compile and link
#include <math.h>
#include <stdio.h>
int main()
{
return printf("%g\n", sqrt(13));
}
with something like
% cc -o foo foo.c
I'll get
/tmp/ccSxBNbM.o: In function `main':
/tmp/ccSxBNbM.o(.text+0xc): undefined reference to `sqrt'
collect2: ld returned 1 exit status
because I haven't linked against the math library, where 'sqrt' lives.
But
% cc -o foo foo.c -lm
works:
% ./foo
3.60555
David S.
>