This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problems with math.h
- To: help-gcc at gnu dot org
- Subject: Re: Problems with math.h
- From: tgakem at pebbles dot chem dot tue dot nl (Eric Meijer)
- Date: 7 Jan 2000 09:17:45 GMT
- Newsgroups: gnu.gcc.help
- Organization: Eindhoven University of Technology, The Netherlands
- References: <85483i$a32$1@nnrp1.deja.com>
- Xref: wodc7nx0 gnu.gcc.help:2384
tobias_meier@my-deja.com wrote:
: Hi all,
:
: compiling this program with the command:
:
: gcc MatheTest.c
[...]
: #include <math.h>
:
: 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)