Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #62555

Re: Need help with an odd error...

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Need help with an odd error...
Date 2015-05-24 15:38 -0700
Organization None to speak of
Message-ID <87wpzxob2h.fsf@kst-u.example.com> (permalink)
References <mjtj7h$nlo$1@speranza.aioe.org>

Show all headers | View raw


"Chris M. Thomasson" <cristom@charter.net> writes:
[...]
> #include <math.h>
> #include <stdio.h>
>
> double
> my_cos(double v)
> {
>    return cos(v);
> }
>
> int main()
> {
>    printf("my_cos(3.14) = %f\r\n", my_cos(3.14));
>
>    return 0;
> }
[...]
> sh-4.3# gcc -o main *.c
>
> /tmp/ccXNUoFK.o: In function `my_cos':
>
> main.c:(.text+0x1b): undefined reference to `cos'

Compile with:

    gcc -o main *.c -lm

(Prepare for a flame war over whether the need to specify "-lm" when
using the math library is a bug or not.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Need help with an odd error... "Chris M. Thomasson" <cristom@charter.net> - 2015-05-24 15:26 -0700
  Re: Need help with an odd error... Keith Thompson <kst-u@mib.org> - 2015-05-24 15:38 -0700
  Re: Need help with an odd error... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-24 23:39 +0100
  Re: Need help with an odd error... James Kuyper <jameskuyper@verizon.net> - 2015-05-24 18:53 -0400
    Re: Need help with an odd error... Stephen Sprunk <stephen@sprunk.org> - 2015-05-24 19:15 -0500
  Re: Need help with an odd error... "Chris M. Thomasson" <cristom@charter.net> - 2015-05-24 16:18 -0700
    Re: Need help with an odd error... "Chris M. Thomasson" <cristom@charter.net> - 2015-05-24 16:54 -0700
    Re: Need help with an odd error... Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-05-27 19:48 +0200

csiph-web