This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Linker problem - undefined reference after including math lib
- To: help-gcc at gnu dot org
- Subject: Linker problem - undefined reference after including math lib
- From: Ari Pollak <compwiz at bigfoot dot com>
- Date: Thu, 11 Nov 1999 17:16:16 -0500
- Newsgroups: comp.lang.c,gnu.gcc.help
- Organization: Monmouth Internet
- Xref: wodc7nx0 comp.lang.c:22105 gnu.gcc.help:1785
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.