log - undefined symbol

Stuart Brooks stuartb@cat.co.za
Wed Mar 8 06:55:00 GMT 2006


>> I tried compiling a C file using gcc 4.0.0 on SunOS5.8. This file
includes
>> math.h there is a call on log() in its code. When I compile this C
file, I
>> get a "undefined symbol referenced error. ld returned 1 exit status."
>>
>> Any idea how this could be fixed?
>>
> Try to add -lm to your linker flags:
> gcc -lm file.c -o executable
> or
> gcc file.c -c -o file.o
> gcc -lm file.o -o executable

You probably want the -lm at the end (after the source or objects):
  gcc -o executable file.o  -lm




More information about the Gcc-help mailing list