This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Error: Undefined reference to ''


jlh wrote:
caojun wrote:
I am trying to compile the following code

 1 #include <stdio.h>
 2 #include <math.h>
 3 int main (){
 4         double a = 0.0;
 5         double b = pow (10,a);
 6         return 1;
 7 }

while I was given the following error message

caojun@ubuntu:~/homework$ gcc -o test.out utility.c
/tmp/ccOQV3cx.o: In function `main':
utility.c:(.text+0x27): undefined reference to `pow'
collect2: ld returned 1 exit status

You fail to mention what OS you're on, but at least on my linux system, 'man pow' says to link with -lm.

jlh

It works.
Thank you very much.

I am using gcc-4.1-multilib, and the system is ubuntu 7.10.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]