public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
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	[thread overview]
Message-ID: <854avp$594$1@news.tue.nl> (raw)
Message-ID: <20000401000000.ccXJA4f0yVwt_0jVr0gqAIoLMDkZBaLZpBBFD2gMe4Y@z> (raw)
In-Reply-To: <85483i$a32$1@nnrp1.deja.com>

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)

  parent reply	other threads:[~2000-04-01  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-07  0:46 tobias_meier
2000-01-07  0:51 ` Alexandre Oliva
2000-04-01  0:00   ` Alexandre Oliva
2000-01-07  1:22 ` Eric Meijer [this message]
2000-04-01  0:00   ` Eric Meijer
2000-01-07  3:01 ` Zoran Cutura
2000-04-01  0:00   ` Zoran Cutura
2000-04-01  0:00 ` tobias_meier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='854avp$594$1@news.tue.nl' \
    --to=tgakem@pebbles.chem.tue.nl \
    --cc=help-gcc@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).