math.h

Jessel Savory plug-devel@lists.PLUG.phoenix.az.us
Sun May 18 21:42:02 2003


This is a multi-part message in MIME format.

------=_NextPart_000_0014_01C31D81.66081BE0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Are you compiling with a -lm to include the math library?

  ----- Original Message -----=20
  From: Phil Winninghoff=20
  To: Developers PLUG=20
  Sent: Sunday, May 18, 2003 5:12 PM
  Subject: math.h


  I just started a project using GNU gcc that requires some rotation of =
graphics. The following snippet will not compile using either Debian 2.2 =
or Red Hat 9:

  #include <stdio.h>
  #include <math.h>

  int main() {
    float x, y, xp, yp, a;
    x =3D 100.0; y =3D 70.0; a=3D0.95;
    xp =3D (x*cos(a)) - (y*sin(a));
    yp =3D (x*sin(a)) + (y*cos(a));
    printf("xp =3D %f\nyp =3D %f\n", xp, yp);
    return 0;
  }

  It compiles using Borland Turbo C++ under MD-DOS.=20
  The gcc GNU compiler tells me it can not find either the sin() or =
cos() functions.
  Can anyone give me some help?





------=_NextPart_000_0014_01C31D81.66081BE0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Are you compiling with a -lm to include =
the math=20
library?</FONT></DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dpegaphil@cox.net href=3D"mailto:pegaphil@cox.net">Phil =
Winninghoff</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20
  title=3Dplug-devel@lists.PLUG.phoenix.az.us=20
  href=3D"mailto:plug-devel@lists.PLUG.phoenix.az.us">Developers =
PLUG</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Sunday, May 18, 2003 5:12 =
PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> math.h</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=3DArial size=3D2>I just started a project using GNU =
gcc that=20
  requires some rotation of graphics. The following snippet</FONT><FONT=20
  face=3DArial size=3D2>&nbsp;will not compile using either Debian 2.2 =
or Red Hat=20
  9:</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>#include &lt;stdio.h&gt;</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>#include &lt;math.h&gt;</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>int main() {</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp; float x, y, xp, yp, =
a;<BR>&nbsp; x =3D=20
  100.0; y =3D 70.0; a=3D0.95;</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp; xp =3D (x*cos(a)) - =
(y*sin(a));</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp; yp =3D (x*sin(a)) + =
(y*cos(a));<BR>&nbsp;=20
  printf("xp =3D %f\nyp =3D %f\n", xp, yp);</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp; return 0;</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>It compiles using Borland Turbo C++ =
under MD-DOS.=20
  </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>The gcc GNU compiler tells me it can =
not find=20
  either the sin() or cos() functions.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Can anyone give me some =
help?</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0014_01C31D81.66081BE0--