From mboxrd@z Thu Jan 1 00:00:00 1970 From: tgakem@pebbles.chem.tue.nl (Eric Meijer) To: help-gcc@gnu.org Subject: Re: Problems with math.h Date: Sat, 01 Apr 2000 00:00:00 -0000 Message-ID: <854avp$594$1@news.tue.nl> References: <85483i$a32$1@nnrp1.deja.com> X-SW-Source: 2000-q1/msg00085.html Message-ID: <20000401000000.ccXJA4f0yVwt_0jVr0gqAIoLMDkZBaLZpBBFD2gMe4Y@z> tobias_meier@my-deja.com wrote: : Hi all, : : compiling this program with the command: : : gcc MatheTest.c [...] : #include : : main() : { : printf("Ergebnis %f \n", exp(2.3)); : printf("Ergebnis %f \n", pow(2,3)); : } [... error:] : /tmp/ccdP8Uys.o(.text+0xe): undefined reference to `exp' : /tmp/ccdP8Uys.o(.text+0x37): undefined reference to `pow' ... research: : gcc -print-search-dirs [...] : searching math.h I get: : /usr/include/math.h : : Ok, using option -B for gcc: : : gcc -B /usr/include/math.h MatheTest.c [...] : Compiling with g++ works: [ yes... ] : But g++ has the same search path as gcc has ! [ yep ] : Who knows what to do ? You stumbled on a typical newbie problem. I must say your research and analysis of the problem are indeed impressive compared to the average (really, no irony here). What you need to do is read the FAQ: http://www.faqs.org/faqs/C-faq/faq/ Most notably item 14.3, but why not read all of it? The reason that g++ does work is in a _library_ it links by default that gcc doesn't. Header files contain only declarations, not the functions themselves. HTH, Eric -- E.L. Meijer (tgakem@pebbles.chem.tue.nl) Eindhoven Univ. of Technology Lab. for Catalysis and Inorg. Chem. (SKA)