From: "Theo. Sean Schulze" <tschulze@teamfinders.org>
To: linux-c-programming@vger.kernel.org
Subject: Re: undefined sqrt()
Date: Fri, 25 Oct 2002 19:27:09 +0200 [thread overview]
Message-ID: <20021025172709.GA25272@teamfinders.org> (raw)
In-Reply-To: <15800.65027.133218.947339@cerise.nosuchdomain.co.uk>
Glynn,
Thanks for the explanation. I understand now. After getting your explanation, I did a bit of web browsing to try to find a page that tells me what libraries I need for which header files, but I haven't been too successful. Do you know of a URL where I could find that info?
Thanks,
Sean
On Fri, Oct 25, 2002 at 09:17:07AM +0100, Glynn Clements hunted and pecked out:
>
> Theo. Sean Schulze wrote:
>
> > Thanks. The "-lm" did it. Why? I see from the gcc man page that the
> > "-l" is a linker option. Am I right that the linker then searches for
> > "libm.a"?
>
> To be precise, it will normally look for libm.so (shared library)
> first (unless the -static switch was used), then look for libm.a.
>
> > Again, why, if I am right, would it need to after I included
> > math.h? Isn't sqrt() in math.h?
>
> The declaration is in math.h, but a declaration simply tells the
> compiler that the function exists, along with the number and types of
> its arguments and its return type.
>
> In order to produce a working program, you have to provide the actual
> code which implements that function. In the case of sqrt(), the code
> is in libm.
>
> For functions which are in libc, you don't have to provide any -l
> switches, as gcc (when used for linking) automatically instructs the
> compiler to link against libc.
>
> --
> Glynn Clements <glynn.clements@virgin.net>
--
Theo. Sean Schulze
tschulze@teamfinders.org
next prev parent reply other threads:[~2002-10-25 17:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-24 20:06 undefined sqrt() Theo. Sean Schulze
2002-10-24 20:17 ` Karthik Vishwanath
2002-10-24 20:50 ` Theo. Sean Schulze
2002-10-24 21:50 ` Karthik Vishwanath
2002-10-25 8:17 ` Glynn Clements
2002-10-25 17:27 ` Theo. Sean Schulze [this message]
2002-10-25 19:29 ` Glynn Clements
2002-10-24 20:28 ` Steven Smith
-- strict thread matches above, loose matches on Subject: below --
2002-10-26 10:07 Ruslan U. Zakirov
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=20021025172709.GA25272@teamfinders.org \
--to=tschulze@teamfinders.org \
--cc=linux-c-programming@vger.kernel.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 NNTP newsgroup(s).