math.h - exp

Claudio Bley bley@cs.uni-magdeburg.de
Thu Sep 4 09:50:00 GMT 2003


On Thu, Sep 04, 2003 at 05:53:54AM +0200, didier wrote:
> I have installed gcc 3.3.1 on a PC-linux system, with bootstrap by gcc 
> 2.96. Every thing was right. But in a test program, the calll of the 
> "exp" function generated an error message " undefined reference to 
> 'exp', thought I include the file <math.h>. What is the reason ?

Including a header file usually is not enough as it usually only
contains function declarations / prototypes. You need to link with the
math library `libm' which provides the compiled code for the various
math functions such as `exp':

gcc prog.c -lm

-- 
Claudio Bley                                 ASCII ribbon campaign (")
Debian GNU/Linux user                         - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \



More information about the Gcc-help mailing list