A blog about the joy, concepts, and precepts of computing through the operating system Unix (or any of its variants.)

Monday, October 16, 2006

GCC - gcc power.c -o power.o -lm

Recently I was writing a C program that involes the pow(x, y) function in math.h. However, gcc could not compile the program, it said "undefined reference to pow". As usual, I got angry and compiled the program again. It still didn't work. So I read a little bit on Usenet and found that you have to tell gcc to link the program, like this:

gcc power.c -o power.o -lmHopefully that will help some of you.However, I got around this later by using g++ or c++.