Linker problem - undefined reference after including math lib
Ari Pollak
compwiz@bigfoot.com
Thu Nov 11 14:18:00 GMT 1999
Before you dismiss this as a complete newbie question, please read on.
The small program that I compiled has all the necessary header files
included (math.h), and it refers to the power() function inside a
function called prn_tbl_of_powers(). power is defined at the beginning
of the program, with:
long power(int, int);
inside prn_tbl_of_powers(), I've got power() being called twice, both
pretty much similar :
printf("%ld", power(i, j));
when compiling, I include the math library with -lm at the end of the
command line, but when linking, it gives me these errors:
/tmp/cchecmWC.o: In function `prn_tbl_of_powers':
/tmp/cchecmWC.o(.text+0x70): undefined reference to `power'
/tmp/cchecmWC.o(.text+0x99): undefined reference to `power'
collect2: ld returned 1 exit status
I am using GNU ld, with egcs-2.91.66. I read through all the relevant
comp.lang.c FAQ info, but none of it seemed to give any helpful
solutions.
--
___ ___
/ _ | / _ \ Ari Pollak - compwiz@bigfoot.com - www.compwiz.nu
/ __ |/ ___/ ICQ #749825 - AOL IM: aripollak
/_/ |_/_/ Make it idiot proof and someone will make a better idiot.
More information about the Gcc-help
mailing list