Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Need help with an odd error... Date: Sun, 24 May 2015 15:38:46 -0700 Organization: None to speak of Lines: 36 Message-ID: <87wpzxob2h.fsf@kst-u.example.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="9be37d943435275679235b07c7947eef"; logging-data="22675"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ycMw2jKGSJu9IcOQL0j2S" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:IjXsgKOUvgkvk3qmE5Liry3cAFE= sha1:lgaq+44gMfIzDkFwhqefTUuuIAQ= Xref: csiph.com comp.lang.c:62555 "Chris M. Thomasson" writes: [...] > #include > #include > > 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 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"